code golf Dec 17, 2010

Code golf is a programming game. Players are presented with a problem such as "sort a list" or "find the largest triangular number smaller than X". They then submit programs which solve this problem, with the goal being to use the least number of keystrokes in typing the program. Players may submit any number of programs. Usually each programming language gets its own scoring category, so as not to give an advantage to anyone based on their preferences. A score is only counted if the program is verified to solve the problem (usually by a computer).

The game began as "perl golf" and was later generalized to include any language, and indeed languages were created for the sole purpose of code golf. Popular choices include perl, PHP, Python, and Ruby.

Its only relation to golf is that lower scores are better.

The largest code golf site online is probably

See also: obfuscated perl, perl bowling, obfuscated C, obfuscated C contest, obfuscated C++ contest

Example, using sed:

The problem---collapse records spread out over multiple lines into a single line each.

Example input:


Example output:

REC a b c d
REC x y

I submit: /^REC/{x;p;x;$p;h;d};H;x;s/\n/ /;$p;x;d

code golf

category: factuals
next: Makefile
previous: Gargoyle

all writing, chronological
next: Makefile
previous: The endless blue sky is not big enough to hold her memories, so it doesn't