A competition to solve a particular problem through the usage and manipulation of strings.
17
votes
0answers
244 views
My god, it's full of spaces!
Some people insist on using spaces for tabulation and indentation.
For tabulation, that's indisputably wrong. By definition, tabulators must be used for tabulation.
Even for indentation, tabulators ...
13
votes
5answers
221 views
Text Processing #1: Hyphenation
Background
This is the first part of a 3-hole golf course on text processing.
The over-arching idea is that if you take an input text and pipe it through the solutions to all three challenges (with a ...
10
votes
36answers
1k views
Find the occurrences of a character in an input string
Challenge
Write a program that, given a string x which is 10 characters long and a character y, outputs the number of times character y occurs in string x.
The shortest program in bytes to do so ...
12
votes
3answers
380 views
How bold is this post?
Preamble
In Stack Exchange markdown, we use ** to bold out text. For example, this markdown:
The **quick brown fox jumps over the lazy** dog.
Renders as:
The quick brown fox jumps over the ...
11
votes
3answers
285 views
Possible Tetris sequences
Write code to figure out whether a run of Tetris pieces could be generated by the official Tetris algorithm. Fewest bytes wins.
Official Tetris games generate the sequence of falling pieces in a ...
19
votes
10answers
2k views
Dead code elimination
Dead code sits there doing nothing, staring at us knowing it will never be executed... but today we can take revenge.
Specification
The input will be a multiline string.
Each line may either be an ...
38
votes
9answers
954 views
Zigzagify a String
Write a program (or function) that takes in a non-empty string of any printable ASCII characters.
Print (or return) a zigzagging chain of the characters in the string with every neighboring pair of ...
97
votes
219answers
13k views
+100
“Hello, World!”
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
25
votes
9answers
1k views
Fond Memories of Past Primes
Consider a prime number p, written in base 10. The memory of p is defined as the number of distinct primes strictly less than p that are contained as substrings of p.
Challenge
Given a non-negative ...
10
votes
4answers
232 views
A backwards relationship
Write a program or function that, given two ASCII strings A and B, will produce strings A' and B' where the common substrings are reversed in their place. The process for finding A' is as follows:
...
58
votes
14answers
2k views
Vertically collapse text
Say I have text like this (each word on one line, with no spaces)
Programming
Puzzles
&
Code
Golf
That makes no sense! It totally defies the laws of physics.
Your challenge is to remedy this ...
8
votes
3answers
266 views
Zig-zag strings
Zig-zag strings
Given a string and a positive integer, output the string in a zig-zag wave pattern with a peak amplitude and character spacing equal to the integer.
This is similar to this question ...
15
votes
23answers
2k views
Sign that word 2!
Sign that word 2!
Not that long ago, I posted a challenge called Sign that word!. In the challenge, you must find the signature of word, which is the letters put in order (e.g. The signature of this ...
15
votes
3answers
296 views
Toggle, Print, Repeat
This challenge is loosely inspired by the unimplemented esolang Pada.
Consider an array of 8 bits, all initialised to zero. We'll introduce a very minimalistic instruction set to print arbitrary ...
10
votes
18answers
548 views
Finding the Value of Words!
Introduction
In the land of [Insert cool name here], people don't buy things with money, because everyone has a severe allergy to paper. They pay eachother with words!
But how is that? Well, they ...
27
votes
27answers
1k views
Twisting Words!
Twisting Words!
Given a string and a positive integer. You must twist the string, back and forth.
Example Input / Output
Input
Programming Puzzles & Code Golf
4
Output
Prog
mmar
ing
zzuP
...
12
votes
41answers
4k views
Sign that word!
What is a Word Signature?
The signature of a word are all of it's letters put in order - the signatures of this, hist and hits are all hist.
The Challenge
Write a program program should ask for an ...
3
votes
8answers
424 views
Simple portmanteau with longest overlap
I've been using a library called Djangular recently, which integrates Django and Angular.
After a while I thought 'Wouldn't it be fun to programmatically generate portmanteau?'
Here are some ...
15
votes
10answers
1k views
Symbolic Differentiation of Polynomials
Symbolic Differentiation 1: Gone Coefishin'
Task
Write a program that takes in a polynomial in x from stdin (1 < deg(p) < 128) and differentiates it. The input polynomial will be a string of ...
10
votes
15answers
3k views
Is 7 l8r than 9? (Is seven later than nine?)
This is a fairly simple code golf challenge. Your program, given an ASCII string, is to parse that string into two strings, which it will evaluate. If the second string is "later" than the first one, ...
48
votes
14answers
6k views
A code golf challenge, m'kay
Mr. Mackey is a South Park character well-known for adding "m'kay" in everything he says.
Write a program or function that transforms a string of text into something Mr. Mackey would say.
M'kay ...
20
votes
18answers
2k views
Swap capitalization of two strings
your shift key is broken. wheNever you type two lines, the cApitaL
LetteRs in them get swappeD. you must write a program to fiX THIS!
Description
The input is two strings, s1 and s2, equal in ...
13
votes
8answers
797 views
Alphabetic Fannkuch
Fannkuch is a classic benchmark program. The name comes from the German "Pfannkuchen"- pancakes- for the algorithm's resemblance to flipping stacks of pancakes. A Fannkuch sequence of numbers is ...
25
votes
10answers
2k views
Sinusoidal text
Goal: Write a program or function which prints an input string in a sinusoidal shape.
The ASCII sinusoid
Here is one period of the sinusoid:
.......
...
44
votes
7answers
2k views
Make the Stretchy Snakes Kiss
A stretchy snake looks something like this:
<||=|||:)~
Each separate sequence of vertical bars (|) in a stretchy snake, known as a stretchy portion, is individually extendable to twice its ...
14
votes
21answers
1k views
Calculate average characters of string
Task
Your task is to produce string that contains average characters of string.
First character of result would be average character of first character (which is first character) and second character ...
16
votes
6answers
386 views
Numbering Hierarchical Outlines
Write a program that takes in a string where every line consists of the character 0 indented by some number of spaces. The top line is not indented and every other line will be indented by at most one ...
20
votes
5answers
785 views
Is it simple or is it hard?
For your hard thing to do, you must make a thing for a computer to do that finds out if some words are explained in a simple way. Something is explained in a simple way if it only uses the ten hundred ...
11
votes
2answers
361 views
Fastest Longest Common Subsequence Finder
Your task is to solve the Longest Common Subsequence problem for n strings of length 1000.
A valid solution to the LCS problem for two or more strings S1, … Sn is any string T of maximal ...
18
votes
25answers
1k views
Remove common leading spaces
When coding in Python, sometimes you want a multiline string within a function, e.g.
def f():
s = """\
Line 1
Line 2
Line 3"""
(The backslash is to remove a leading newline)
If you ...
19
votes
3answers
330 views
Accentuated abjad English (ōcćnt̮ōt̖d ōbj̄d óngḷsh)
An Abjad is a writing system where each symbol stands for a consonant, and where vowels are omitted. An impure Abjad is an abjad in which there are additionals symbols for vowels, usually diactrics.
...
36
votes
17answers
3k views
Garlandification
Garland Words
A garland word is a word which can be strung together like a garland, because it ends with the same letters it starts with. These groups of letters can even overlap!
For example, ...
28
votes
29answers
3k views
Chunky vs. Smooth Strings
Consider a string of length N, such as Peanut Butter with N = 13. Notice that there are N-1 pairs of neighboring characters in the string. For Peanut Butter, the first of the 12 pairs is Pe, the ...
13
votes
4answers
281 views
Implement bzip2's run-length encoding
Background
After applying the BWT (as seen in Burrows, Wheeler and Back) and the MTF (as seen in Move to the printable ASCII front), the bzip2 compressor applies a rather unique form of run-length ...
38
votes
30answers
5k views
Backhanded^H^H^H^H^H^Hspaces
On some terminals, pressing backspace generates the control code ^H to delete the previous character. This gave rise to a snarky idiom where edits are feigned for comedic effect:
Be nice to this ...
17
votes
29answers
2k views
The n-th Ternary
I define the n-th ternary as a ternary that returns n and has the form:
1 ? 2 ? 3 ? n - 1 ? n : 0 : 0 : 0 # n - 1 zeroes
Write a function or complete program that given an input n will output or ...
10
votes
10answers
529 views
Decimal Time of Day Conversion
Introduction
Time is confusing. Sixty seconds to a minute, sixty minutes to an hour, twenty-four hours to a day (and not to mention that pesky am/pm!).
There's no room for such silliness nowadays, ...
6
votes
4answers
734 views
Necklace stones puzzle
Given a necklace with color stones (yellow, white, brown, etc.) of at least two different colors, we describe that necklace using letters that correspond to each color, choosing an arbitrary starting ...
9
votes
5answers
577 views
Shortest Longest Common Subsequence Code
Your task to to solve the SLCSC problem, which consists in finding the shortest possible code to solve the Longest Common Subsequence problem.
A valid solution to the LCS problem for two or more ...
18
votes
7answers
607 views
Move to the printable ASCII front
Background
The move-to-front transform (MTF) is a data encoding algorithm designed to improve the performance of entropy encoding techniques.
In the bzip2 compression algorithm, it is applied after ...
20
votes
16answers
2k views
Write a program that finds the most occurring paired letter in a string
The program must output the letter that is paired the most. For example, if your program was given the following string:
"Sally's friend Bobby searched for seashells."
it must output L because "ll" ...
10
votes
6answers
535 views
Print an ascii spiral in O(log n) memory
You may write a program or function that receives an odd, positive integer n, where n >= 3, as either a function argument, command line arguments, or on STDIN (or equivalent for your system), and ...
32
votes
14answers
3k views
Staircase writing
Write a program or a function that will output a given string in a staircase fashion, writing each part of a word that starts with a vowel one line below the previous part.
For example:
Input: ...
1
vote
6answers
290 views
Number of characters in an integer's name [duplicate]
The goal of this challenge is to show how many characters are in the name of a given integer. This is code golf, so the smallest code wins.
RULES
The input will be between 0 and 100 (inclusive). If ...
45
votes
25answers
5k views
First code golf decathlon
Tasks
All competitors try to solve the following list of 10 tasks:
math
Read a positive integer n from input and return the sum of the cubes of the first n non-negative integers.
For input 1, ...
32
votes
33answers
3k views
Stretching Words
Write a program or function that duplicates letters in a word, so that all the duplicated letters arranged from left to right in the word would form the input array.
For example:
input: chameleon, ...
18
votes
23answers
2k views
Counter counter
In typography, a counter is the area of a letter that is entirely or partially enclosed by a letter form or a symbol. A closed counter is a counter that is entirely enclosed by a letter form or ...
37
votes
22answers
4k views
Ninjas and Monkeys and Bears, Oh My!
This challenge is NinjaBearMonkey's prize for winning my Block Building Bot Flocks! challenge with the Black Knight submission. Congratulations NinjaBearMonkey!
The challenge here is fairly simple, ...
8
votes
4answers
227 views
Compute minimal string segment sizes
A common optimization to save space in binaries is to merge string literals where one literal is the suffix of another. For instance, a binary with the string literals
a: foobar
b: bar
c: barbaz
d: ...
12
votes
1answer
250 views
Each step of the Levenshtein distance
In this challenge you will write a program that takes two newline-separated strings, s1 (the first line) and s2 (the second line), as input (STDIN or closest). You can assume that the length of s1 ...