Questions tagged [code-golf]

Code Golf is a game that was played on Stack Overflow in its early days, but it is now considered off-topic. Code Golf challenges should be posted in Code Golf & Coding Challenges.

Note: This tag is currently blacklisted and can no longer be used.

Code Golf is a game that was played on Stack Overflow in its early days but is now considered off-topic. Fortunately, there's an entire site dedicated to avid golfers - check out Code Golf & Coding Challenges!.

139 questions
160
votes
129 answers

What's the shortest code to cause a stack overflow?

To commemorate the public launch of Stack Overflow, what's the shortest code to cause a stack overflow? Any language welcome. ETA: Just to be clear on this question, seeing as I'm an occasional Scheme user: tail-call "recursion" is really iteration,…
C. K. Young
  • 219,335
  • 46
  • 382
  • 435
156
votes
59 answers

Build an ASCII chart of the most commonly used words in a given text

The challenge: Build an ASCII chart of the most commonly used words in a given text. The rules: Only accept a-z and A-Z (alphabetic characters) as part of a word. Ignore casing (She == she for our purpose). Ignore the following words (quite…
ChristopheD
  • 112,638
  • 29
  • 165
  • 179
152
votes
28 answers

Code Golf: Lasers

The challenge The shortest code by character count to input a 2D representation of a board, and output 'true' or 'false' according to the input. The board is made out of 4 types of tiles: # - A solid wall x - The target the laser has to hit / or…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
95
votes
26 answers

Code Golf - π day

The Challenge Guidelines for code-golf on SO The shortest code by character count to display a representation of a circle of radius R using the *character, followed by an approximation of π. Input is a single number, R. Since most computers seem to…
John La Rooy
  • 295,403
  • 53
  • 369
  • 502
88
votes
30 answers

Code Golf: Four is magic

The puzzle A little puzzle I heard while I was in high school went something like this... The questioner would ask me to give him a number; On hearing the number, the questioner would do some sort of transformation on it repeatedly (for example, he…
Platinum Azure
  • 45,269
  • 12
  • 110
  • 134
88
votes
22 answers

Code Golf: Piano

The challenge The shortest code by character count to output a part of a piano keyboard starting from input note in a given length. Input will be composed of a note ([ACDFG]#|[A-G]) to start printing the keyboard from and a positive number…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
86
votes
70 answers

Code Golf: Collatz Conjecture

Inspired by http://xkcd.com/710/ here is a code golf for it. The Challenge Given a positive integer greater than 0, print out the hailstone sequence for that number. The Hailstone Sequence See Wikipedia for more detail.. If the number is even,…
Earlz
  • 62,085
  • 98
  • 303
  • 499
83
votes
14 answers

Code Golf: Playing Tetris

The basics: Consider the following tetrominoes and empty playing field: 0123456789 I O Z T L S J [ ] [ ] # …
ChristopheD
  • 112,638
  • 29
  • 165
  • 179
76
votes
43 answers

Evaluating a string of simple mathematical expressions

Challenge Here is the challenge (of my own invention, though I wouldn't be surprised if it has previously appeared elsewhere on the web). Write a function that takes a single argument that is a string representation of a simple mathematical…
Noldorin
  • 144,213
  • 56
  • 264
  • 302
76
votes
24 answers

Code Golf: Conway's Game of Life

The Challenge: Write the shortest program that implements John H. Conway's Game of Life cellular automaton. [link] EDIT: After about a week of competition, I have selected a victor: pdehaan, for managing to beat the Matlab solution by one character…
76
votes
67 answers

Code Golf: Numeric equivalent of an Excel column name

The challenge The shortest code by character count that will output the numeric equivalent of an Excel column string. For example, the A column is 1, B is 2, so on and so forth. Once you hit Z, the next column becomes AA, then AB and so on. Test…
Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
61
votes
13 answers

Code Golf: Playing Cubes

The challenge The shortest code by character count, that will output playing bricks tower series according to user input. The input will be a series of numbers (positive, negative and zero) that represents the height of the current cube tower…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
57
votes
32 answers

Convert a string into Morse code

The challenge The shortest code by character count, that will input a string using only alphabetical characters (upper and lower case), numbers, commas, periods and question mark, and returns a representation of the string in Morse code. The Morse…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
53
votes
7 answers

Code Golf: Regex parser

The goal Today's Code Golf challenge is to create a regex parser in as few characters as possible. The syntax No, I'm not asking you to match Perl-style regular expressions. There's already a very reliable interpreter for those, after all!…
Platinum Azure
  • 45,269
  • 12
  • 110
  • 134
53
votes
4 answers

Code Golf: Running Water

The challenge The shortest code by character count to identify and mark water depressions in the ASCII representation of a land from input. Input will be an ASCII representation of a landscape, having hills, valleys and flat lands. The program…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
1
2 3
9 10