A competition to solve a particular problem through the usage and manipulation of strings.

learn more… | top users | synonyms

14
votes
5answers
341 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 ...
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: ...
10
votes
6answers
430 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 ...
40
votes
22answers
4k 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, ...
69
votes
106answers
18k views

Sing Happy Birthday to your favourite programming language

Your favourite programming language has just had a birthday. Be nice and sing the Happy Birthday song to him (or her, if you will). Of course you should accomplish this by writing a program in that ...
19
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" ...
17
votes
14answers
1k views

Topographic Strings

Here is some example input, so I can explain what the problem is: ((1 2)(3 (4 5) moo)) (i (lik(cherries)e (woohoo))) Think of this line of text as a topographic map of some mountains. Each set of ...
22
votes
42answers
3k views

Convert C header names to C++ header names

In the C standard library, header names end with a .h suffix: stdio.h In C++, those header names are available in an alternative form, with a c prefix instead: cstdio Write a function that ...
13
votes
1answer
729 views

Rearranging Words

You should write a program which receives two strings as input and outputs a sequence of movements which rearrange the first string into the second. You should use as few moves as you can. Both ...
15
votes
3answers
679 views

How many characters per character?

At http://shakespeare.mit.edu/ you can find the full text of each of Shakespeare's plays on one page (e.g. Hamlet). Write a script that takes in the url of a play from stdin, such as ...
1
vote
6answers
276 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 ...
36
votes
20answers
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, ...
30
votes
30answers
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 ...
38
votes
25answers
3k views

Fake Marquee Text

In this challenge fake marquee text is text that is shown part by part, in a scrolling-like fashion. Some examples: testing 4 t te tes test esti stin ting ing ng g hello 2 h he el ll lo o ...
22
votes
33answers
3k views

Generating a single string with an Oxford comma from a list

What are some clever (brief and idiomatic) approaches to taking a list of strings and returning a single properly punctuated string built from the list, with each element quoted. This came up for me ...
12
votes
28answers
2k views

Count the number of vowels in each word of a string

This is a rather easy challenge. Challenge Input will contain a string (not null or empty) of maximum length 100. Output the number of vowels in each word of the string, seperated by spaces. Rules ...
19
votes
9answers
787 views

Formatting a Lisp-like Syntax

Background (Based on a true, heart-wrenching story) In my time, I've played around with Lisp and similar languages often. I've written with them, ran them, interpreted them, designed them, and made ...
8
votes
0answers
1k views

Longest common substring

This challenge is about writing code to solve the following problem. Given two strings A and B, your code should output the start and end indices of a substring of A with the following properties. ...
24
votes
9answers
2k views

Word Search Puzzle

Given a rectangular text as a word search puzzle and a search string, determine if the text contains the search string. The search string may appear: horizontally, vertically or diagonally forwards ...
19
votes
7answers
774 views

A Basic Pyth-like Syntax Checker

Pyth is a golfing language based on Python. It uses prefix notation, with each command having a different arity (number of arguments it accepts). Your task is to write a syntax checker for a ...
8
votes
4answers
221 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: ...
5
votes
1answer
267 views

Create a basic autocorrecting spell checker

In this challenge, you have to implement a basic spell checker and autocorrector. Your program will use the first input as a source for a dictionary of words, and will use that to autocorrect the ...
11
votes
1answer
231 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 ...
13
votes
3answers
423 views

Burrows, Wheeler and Back

Background The Burrows–Wheeler transform (BWT) is a reversible permutation of the characters of a string that results in large runs of similar characters for certain types of strings such as plain ...
40
votes
6answers
2k views

Language Design: 2-D Pattern Matching

This is Fortnightly Challenge #6. Theme: Language Design There's a chatroom for this challenge. Come and join us if you want to discuss ideas! And now for something completely different... This ...
52
votes
79answers
10k views

Print the alphabet without using each vowel

Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'. Your task is to write a set of (up to 5) programs in any language (which has a ...
15
votes
2answers
314 views

Fix the Braces, etc

Your mission, should you choose to accept it, is to add the minimum number of parentheses, braces, and brackets to make a given string (containing only parentheses, braces, and brackets) have correct ...
6
votes
9answers
434 views

Shift characters in a string

In this challenge, you are required to shift characters in an inputted string n number of times and output the shifted string Input Input will first contain a string. In the next line, an integer, ...
15
votes
34answers
3k views

Reverse stdin and place on stdout

Requirements: Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.) Output the ...
8
votes
8answers
534 views

Cambridge Transposition

I'm sure most, if not all, of you have come across this at some point or another: Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, ...
17
votes
12answers
893 views

Expand an encoded string

There's the classic run length encoding and decoding. input output a3b2c5 aaabbccccc And that's fairly straight forward and done before. The challenge is to also account for a non-standard ...
12
votes
18answers
793 views

QuickGolf - Heads or Tails

Instructions Given an unknown input string i with a value of either heads or tails, return 1 for heads or -1 for tails with the shortest code. Sample not golfed code (55b): if(i == "heads"){ ...
18
votes
9answers
1k views

Caesar-Cypher-Mania

The Caesar Cypher is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII ...
22
votes
22answers
2k views

Caesar equivalence

Two strings are "Caesar equivalent" if the distance (counting up) between the corresponding characters are the same. Yes, I made this term up. Here's an example: "Abc" and "Cde" are equivalent ...
5
votes
9answers
580 views

Take first letter of each word, leave spaces and punctuation

Shrink each word in a string of group of strings to single letters delineated by spaces or punctuation. Example I'm a little teapot, short and stout. Here is my handle, here is my spout. When I get ...
48
votes
20answers
5k views

Significant Whitespace

We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20). For this challenge, you're to write two programs or functions in the same programming language, ...
25
votes
16answers
3k views

Shortest Unique Substrings

Input An alphanumeric string s. Output The shortest string that occurs exactly once as a (contiguous) substring in s. Overlapping occurrences are counted as distinct. If there are several ...
6
votes
16answers
1k views

Stripping off extra spaces from a string

You are given a string. Output the string with one space per words. Challenge Input will be a string (not null or empty), surrounded with quotes(") sent via the stdin. Remove leading and trailing ...
1
vote
1answer
91 views

Gode-Colf: Wipping Flords around [duplicate]

Here is another short string related code-golf. You must write a full program that reads a string (from STDIN or as command line arguments, as long as you specify which) and wips the flords around ...
-5
votes
5answers
204 views

Return every N-th word of a string

Your goal is to write a program that, given a number N and a string as input, will return a string containing every Nth word of the original string, starting from the first word. Sample ...
32
votes
44answers
3k views

Capitalize first letter of each word of input

This is a relatively quick one, but I'm sure you'll like it. Codegolf a program that will take input in the form of a sentence and then provide the output with the first letter capitalized in each ...
24
votes
35answers
3k views

Check whether letters of word are in alphabetical order

Write a function/program that accepts a string of lower/uppercase letters [A-Za-z] as input, that checks whether the occuring letters are unique and in alphabetical order (ignoring lower and ...
11
votes
12answers
2k views

QuickGolf - Barry the messy developer #2

This is a follow-up of QuickGolf - Ignore the noise #1 the only problem being that Barry has made things even worse for us. Lets see what happened Update I've added code to create random ...
14
votes
14answers
2k views

QuickGolf - Ignore the noise #1

Instructions Barry is a not so good backend developer in charge of a small API that should give you information about purchases made in a client's shop. However, he hasn't done a great job and your ...
15
votes
12answers
784 views

Extract a string from a given string

You are given a string and two characters. You have to print the string between these characters from the string. Input Input will first contain a string (not empty or null). In the next line, there ...
13
votes
24answers
2k views

Convert a string to its Rövarspråket equivalent

Rövarspråket Rövarspråket is a word game played by Swedish children, from the books about Kalle Blomkvist by Astrid Lindgren. The basic rules are as follows (from Wikipedia): Every consonant ...
9
votes
7answers
341 views

Find the longest musical substring

A musical string is any string that can be played on a piano keyboard. For those of us who weren't forced to learn the piano as kids, here is what the keyboard looks like. So the string feed a ...
18
votes
7answers
527 views

Optimize the Scralphabet

Scralphabet A normal bag of Scrabble tiles contains the following letters (? is a blank tile, which can stand for any other letter): ...
21
votes
7answers
1k views

Reassuring parables

Quite a few people here are probably avid XKCD readers. So, I figure I'd challenge you guys to do something that Megan can do easily: make a script that generates thousands of reassuring parables ...