Questions tagged [rosetta-stone]

Encouraging users to solve a challenge using as many different languages as they know. The end goal is to demonstrate how the same challenge is accomplished in different programming languages.

66 questions
46
votes
41 answers

Code Golf: Morris Sequence

The Challenge The shortest code by character count that will output the Morris Number Sequence. The Morris Number Sequence, also known as the Look-and-say sequence is a sequence of numbers that starts as follows: 1, 11, 21, 1211, 111221, 312211,…
Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
42
votes
35 answers

Code Golf: Tic Tac Toe

Post your shortest code, by character count, to check if a player has won, and if so, which. Assume you have an integer array in a variable b (board), which holds the Tic Tac Toe board, and the moves of the players where: 0 = nothing set 1 = player…
Aistina
  • 12,435
  • 13
  • 69
  • 89
41
votes
33 answers

Code Golf: The wave

The challenge The shortest code by character count to generate a wave from the input string. A wave is generated by elevating (line-1) a higher character, and degrading (line+1) a lower character. Equal characters are kept on the same line (no…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
40
votes
15 answers

Code golf: the Mandelbrot set

Usual rules for the code golf. Here is an implementation in python as an example from PIL import Image im = Image.new("RGB", (300,300)) for i in xrange(300): print "i = ",i for j in xrange(300): x0 = float( 4.0*float(i-150)/300.0…
Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
39
votes
22 answers

Code Golf: Number to Words

The code golf series seem to be fairly popular. I ran across some code that converts a number to its word representation. Some examples would be (powers of 2 for programming fun): 2 -> Two 1024 -> One Thousand Twenty Four 1048576 -> One Million…
Jason Z
  • 13,122
  • 15
  • 50
  • 62
37
votes
21 answers

Code Golf: Sierpinski's Triangle

The challenge The shortest code, by character count to output an ASCII representation of Sierpinski's Triangle of N iterations made from the following ASCII triangle: /\ /__\ Input is a single positive number. Test cases Input: 2 Output: …
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
36
votes
14 answers

Code Golf - Banner Generation

When thanking someone, you don't want to just send them an e-mail saying "Thanks!", you want to have something FLASHY: Input: THANKS!! Output: TTT H H AAA N N K K SSS !!! !!! T H H A A NNN K K S !!! !!! T HHH AAA NNN KK SSS !!! !!! T H H…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
36
votes
15 answers

Code Golf: Spider webs

The challenge The shortest code by character count to output a spider web with rings equal to user's input. A spider web is started by reconstructing the center ring: \_|_/ _/ \_ \___/ / | \ Then adding rings equal to the amount…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
36
votes
12 answers

Code Golf: Musical Notes

The challenge The shortest code by character count, that will output musical notation based on user input. Input will be composed of a series of letters and numbers - letters will represent the name of the note and the number will represent the…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
36
votes
26 answers

Code Golf: Seven Segments

The challenge The shortest code by character count to generate seven segment display representation of a given hex number. Input Input is made out of digits [0-9] and hex characters in both lower and upper case [a-fA-F] only. There is no need to…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
31
votes
46 answers

Code Golf: Leibniz formula for Pi

I recently posted one of my favourite interview whiteboard coding questions in "What's your more controversial programming opinion", which is to write a function that computes Pi using the Leibniz formula. It can be approached in a number of…
Greg Beech
  • 133,383
  • 43
  • 204
  • 250
31
votes
14 answers

Code Golf: Beehive

The challenge The shortest code by character count that will generate a beehive from user input. A beehive is defined a a grid of hexagons in a size inputted by the user as two positive numbers greater than zero (no need to validate input). The…
LiraNuna
  • 64,916
  • 15
  • 117
  • 140
30
votes
17 answers

Code Golf: 1x1 black pixel

Recently, I used my favorite image editor to make a 1x1 black pixel (which can come in handy when you want to draw solid boxes in HTML cheaply). Even though I made it a monochrome PNG, it came out to be 120 bytes! I mean, that's kind of steep. …
Joey Adams
  • 41,996
  • 18
  • 86
  • 115
29
votes
50 answers

Palindrome Golf

The goal: Any language. The smallest function which will return whether a string is a palindrome. Here is mine in Python: R=lambda s:all(a==b for a,b in zip(s,reversed(s))) 50 characters. The accepted answer will be the current smallest one - this…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
27
votes
9 answers

Code-Golf: Friendly Number Abbreviator

Based on this question: Is there a way to round numbers into a friendly format? THE CHALLENGE - UPDATED! (removed hundreds abbreviation from spec) The shortest code by character count that will abbreviate an integer (no decimals). Code should…