A competition to solve a particular problem through the usage and manipulation of strings.
11
votes
14answers
1k views
javascript left-pad golf [on hold]
In the wake of the left-pad npm package fallout, let's have a javascript-only code golf for implementing left-pad.
Submissions are considered correct if they pass the original left-pad test suite ...
14
votes
4answers
551 views
Make this code explanation pretty again
Introduction
Most code-golfers here add explanations to their submissions, so it's easier to understand what's going on. Usually the codelines go on the left and the corresponding explanation to the ...
14
votes
67answers
2k views
Full Width Text
Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes:
F u l l w i d t h t e x t i s t e x t t h ...
17
votes
6answers
888 views
Length-encode a string
Suppose we use the following rules to pull a single string from another string, one containing only ASCII printable characters and called an *-string. If the string runs out before the process halts, ...
-2
votes
0answers
54 views
How to access other comma separated values from a txt file. C++ [closed]
ifstream f("events.txt");
if (f.is_open())
{
string l,t;
string myArray[5];
int i = 0;
while (getline(f, l))
{
getline(stringstream(l), t, ',');
cout << t ...
16
votes
11answers
1k views
Creating a falling ball map
Introduction
For the ones who never heard of this game before. You are playing a ball which needs to survive as long as possible. This is done by moving to the left or right, going to the holes. ...
9
votes
4answers
247 views
Replace alias to form phrases
Inspired by the C-directive #define.
Challenge
Given one phrase with some alias, and one array with each alias text. Output the initial phrase replacing each alias with its respective text.
An ...
7
votes
4answers
299 views
Naïve Markov Chain Word Generation
There are many ways to generate random words. You can take random syllables from a set, you can use n-tuples, probably neural networks (what can't they do?), alternating between consonants and vowels, ...
9
votes
1answer
236 views
Golf English – using contractions
I have not laughed as much from Stack Exchange content as I have from this. I think you all will enjoy this challenge, as it is inspired by what is over there.
You will write a function or program ...
2
votes
1answer
147 views
Translate Java methods to fields
So, recently, I found myself reformatting my code for Vitsy to using anonymous class instances for commands rather than the normal method approach. For those who don't know, anonymous class instance ...
39
votes
6answers
743 views
There's an ant on my Rubik's Cube
A standard, solved, 3×3×3 Rubik's Cube has 6 differently colored faces, where each face is a 3×3 grid of squares of one color. The white face is opposite the yellow, the red opposite ...
20
votes
25answers
2k views
Making an acronym
Objective
Your goal is to make a program that converts an input to its acronym. Your input is guaranteed to have only letters and spaces. The input will have exactly one space between words. You must ...
14
votes
3answers
332 views
Hungarian alphabetical order
For those who wish a lot more challenge then the old Spanish alphabetical order, let's take a look at how the Hungarian alphabet is ordered.
a, á, b, c, cs, d, dz, dzs, e, é, f, g, gy, h, i, í, j, ...
11
votes
2answers
175 views
Word Search Helper
I've been doing word searches recently, and I thought it would be so much easier if all of the words read left-to-right. But rewriting all the lines takes a lot of effort! So I'm enlisting code ...
42
votes
16answers
2k views
Rotate the dots
Introductions
A 2×n Boolean matrix can be represented as a string of the four characters . ':.
The string has an "upper row" and a "lower row", with dots representing 1s and empty spaces ...
20
votes
6answers
1k views
Old Spanish alphabetical order
Before 1994, Spanish dictionaries used alphabetical order with a peculiarity: digraphs ll and ch were considered as if they were single letters. ch immediately followed c , and ll immediately followed ...
11
votes
2answers
371 views
How many sides does this polygon have?
So in 1st grade math, you learn the names of polygons. Three sides is a triangle, 4 is a square, and 5 is a pentagon. However, in 1st grade honors, you go a bit further.
Your challenge
There is a ...
-1
votes
16answers
324 views
Print all the numbers! (At least, as many as possible.) [closed]
Your task is to print a number. Simple, right? It is simple, but not as simple as this. The first answer is to print the number 1, the second answer is to print the number 2, etc.
Rules
The first ...
3
votes
5answers
381 views
Electoral votes from state name
Given a the name of a state of the United States as a string (with case), return the number of votes the state has in the Electoral College. Write a full program or function, and take input and output ...
-5
votes
4answers
145 views
Solve an algebraic expression
The Challenge
Your task is to create a program that can solve an algebraic equation.
Input
Input will consist of a String. The string will be an equality involving the variable x, and follows the ...
12
votes
3answers
389 views
Half-reverse a binary string
This is a follow-up question to my Puzzling.SE question: I asked if there’s a function f mapping Boolean strings to Boolean strings, so that f(f(b)) = reverse(b) for all input strings b. (By reverse, ...
16
votes
1answer
269 views
The puppy command
The puppy utility takes a filename as input, and does exactly what you would expect a puppy to do: it shreds it!
How to shred
Rip out the pages with your teeth Split the input file on newlines.
...
35
votes
34answers
4k views
Making a coin fair
You have a coin that produces 0 or 1. But you suspect the coin may be biased, meaning that the probability of 0 (or 1) is not necessarily 1/2.
A well known procedure to "transform" a biased coin into ...
17
votes
2answers
225 views
Follow the dots
The Challenge
Given a rectangular grid of characters
A B C D E
F G H I J
K L M N O
P Q R S T
and a grid with the same dimensions of dots and spaces
. . .
. . .
. .
. . .
...
7
votes
1answer
106 views
Find the Words on the Grid!
Write a program or function that extracts a word from a wordsearch using its start and end coordinates.
The Input
Your program or function should accept three parameters: the start coordinate, the ...
18
votes
13answers
950 views
Merging two strings
Introduction
Let's say that S1 = a...b and S2 = ..c... If we place them on top of each other, we get:
a...b
..c..
We merge both strings, with the . as the liquid character (which can overlapped). ...
22
votes
9answers
2k views
The XOROR sequence
Cellular Automata are truly fascinating. The ones that are usually talked about are the binary ones, i.e., the ones representable by a number. However, those, in my opinion, have been done to death. ...
13
votes
5answers
281 views
Generalization of abbreviations
Given an input of a list of words and their abbreviations, output the pattern
by which the abbreviations can be formed.
Let us take the example input of
potato ptao
puzzle pzze
as an example (that ...
47
votes
15answers
3k views
Shifty Eyes Shifting I's
Shifty-eyes ASCII guys like to shift ASCII Ii's:
>_> <_< >_< <_>
Given a string of shifty-guys, spaced apart or separate lines, shift the Ii's side to side, left the wall ...
7
votes
0answers
179 views
Human Friendly Filename Detection
Introduction
File names can be wildly varying things, ranging from a simple blah.txt to 303549020150514101638190-MSP0.txt. The former is usually human generated, while the latter is often machine ...
31
votes
12answers
3k views
Convert to camelCase
The Challenge
I was reading Google's Java Style Guide the other day and stumbled over their algorithm to convert any arbitrary string into camelCase notation. In this challenge you have to implement ...
4
votes
3answers
84 views
Symbolic Differentiation of Composed Functions
Symbolic Differentiation 2: Back on the Chain Gang
Task
Write a program that takes in a certain sort of function from stdin and differentiates it with respect to x, using the chain rule.* The input ...
18
votes
3answers
377 views
Text on a circle
Write a program or function that prints an input string around the discrete circle that has the minimum possible radius. For example, for input This is an example, your program should output:
a si ...
11
votes
1answer
172 views
Help Jason format his JSON
Jason has a big JSON but it's unreadable, so he needs to prettify it.
Formatting Spec
The JSON has 4 different types:
Numbers; Just 0-9
Strings; Double quoted " strings escaped with \
Arrays; ...
22
votes
12answers
1k views
Crunch vowels out of a string
Task description
Sometimes, you really need to fit something you’re writing in a small space. It may be tempting to drop the vowels and wrt lk ths – and failing that, who really needs spaces? ...
14
votes
0answers
89 views
Expand a bash brace expansion
For mostly historical reasons, bash is quite a hodge-podge of syntax and programming paradigms - this can make it awkward and sometimes frustrating to golf in. However it does have a few tricks up ...
17
votes
1answer
224 views
Write a Chat Ping Counter
Your task is to write a program, that given a list of chat messages, count how many times each person gets pinged, so I can know how popular everyone is. But, since I have to do it surreptitiously, I ...
4
votes
0answers
60 views
What is the “Ant-Difficulty” of this string? [duplicate]
I think about if I was turned into an ant, I'd want my loved ones to
know, so I thought of a plan- I'd gather twigs and leaves and write my
name on the ground, Then I'd wait for my family and ...
16
votes
2answers
245 views
Chain words crossword-style
The challenge
Given a list of words ["Programming", "Puzzles", "Code", "Golf"] output the words crossword-style:
P r o g r a m m i n g
u
z
z
G l
C o d e
l s
f
...
23
votes
21answers
1k views
Orthogonal Orientation
Task: Given an input consisting of exactly one of the characters <>^v, output a second input consisting of the printable ASCII characters (from space to tilde), oriented with the arrow.
Let's ...
31
votes
18answers
1k views
Output all strings
Given a set of letters, output all strings made of those letters. (This is Kleene star of the set.) For example, for {'a','b'}, the strings are:
'', 'a', 'b', 'aa', 'ab', 'ba', 'bb', 'aaa', 'aab', ...
22
votes
17answers
1k views
Reimplement the wc coreutil
This challenge is similar to this old
one, but with some unclear
parts of the spec hammered out and less strict I/O requirements.
Given an input of a string consisting of only printable ASCII and ...
18
votes
2answers
155 views
Transpose a word cloud
Background
I wanted to make a pretty word cloud, like this:
these are
words
floating
I computed the (x,y)-coordinates of the first letter of each word, plugged them into my word ...
28
votes
24answers
2k views
Manage Trash So
It's become somewhat of a tradition in PPCG that some users temporarily change their names by an anagram (a new name formed by reordering the letters of the old).
Sometimes it gets difficult to find ...
1
vote
1answer
155 views
Build a Calculus Interpreter I [closed]
A struggling manufacturer named Tennessee Instrumental is desperate to get into the calculator business. Problem is, they don't have any software engineers on payroll, and the deadline is coming up ...
27
votes
18answers
1k views
Locate and rotate
The task
This is a simple challenge.
Your input is a single non-empty string, containing only digits 0123456789 and hashes #.
It will contain exactly one run of digits, which encodes a nonnegative ...
6
votes
3answers
175 views
LaTeX Table Generator
Write a function or program which, given a number of lines and columns, generates a corresponding tabular environment for LaTeX with no data in it.
Table format and tabular Environment
Here is an ...
46
votes
43answers
5k views
Is it a lipogram?
A lipogram is a block of words that omits a particular symbol. Right now, I am avoiding our fifth symbol of 26 that commonly show up. You should know by now what I am omitting. If not, look up ...
9
votes
4answers
152 views
ASCII dank star
Input description
A string (for best results, all characters should be printable and be the same width).
Output description
A character star following the pattern:
0 0 0
1 1 1
222
0123210
...
28
votes
15answers
985 views
Unslice a string
Given an input of a list of slices of a string, output the original string.
Each slice will be given as a list of length 2, containing the start position
of the slice (an integer ≥0) and the slice ...