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
0
votes
1
answer
166
views
Need help deconstructing RosettaStone Huffman Code
I'm taking a class in C with a couple of friends. We're doing a project on Huffman Encoding and I am trying to understand the Rosetta stone version of the code. I think I've figured most of it out, ...
19
votes
9
answers
2k
views
CodeGolf: Find the Unique Paths
Here's a pretty simple idea, in this pastebin I've posted some pair of numbers. These represent Nodes of a directed graph. The input to stdin will be of the form, (they'll be numbers, i'll be using an ...
46
votes
41
answers
6k
views
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 ...
83
votes
14
answers
7k
views
Code Golf: Playing Tetris
The basics:
Consider the following tetrominoes and empty playing field:
0123456789
I O Z T L S J [ ]
...
25
votes
6
answers
3k
views
Code Golf: draw ascii art stars
Since this week noone has posted a code-golf challenge, I'll give it a try. I do it so you can do something other than playing with swords during those long compile cycles.
The challenge:
Draw ASCII ...
25
votes
14
answers
4k
views
Code Golf: Calculate Orthodox Easter date
The Challenge
Calculate the Date of the Greek Orthodox Easter (http://www.timeanddate.com/holidays/us/orthodox-easter-day) Sunday in a given Year (1900-2100) using the least amount of characters.
...
49
votes
33
answers
7k
views
Code Golf: Happy Primes!
It's Sunday, time for a round of code golf!
Challenge
Write the shortest source code by character count to determine if an input number is a "happy prime", "sad prime", "happy non-prime", or "sad ...
53
votes
7
answers
9k
views
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 ...
76
votes
24
answers
20k
views
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 ...
12
votes
9
answers
2k
views
Code Golf: Frobenius Number
Write the shortest program that calculates the Frobenius number for a given set of positive numbers. The Frobenius number is the largest number that cannot be written as a sum of positive multiples of ...
18
votes
40
answers
4k
views
Code-golf: Output multiplication table to the Console
I recently pointed a student doing work experience to an article about dumping a multiplication table to the console. It used a nested for loop and multiplied the step value of each.
This looked like ...
20
votes
12
answers
2k
views
Code Golf: Build Me an Arc
Challenge
The shortest program by character count that accepts standard input of the form X-Y R, with the following guarantees:
R is a non-negative decimal number less than or equal to 8
X and Y are ...
18
votes
6
answers
3k
views
Code Golf: Who has the best poker hand?
I love challenges like this, I'll hopefully submit my answer soon.
Which player has the best 7 card hand?
Given an unordered list of 9 cards (separated by a space), work out which player has the ...
20
votes
14
answers
1k
views
Code Golf - Generate nearby page numbers based on the current page
The challenge is to create an algorithm for generating a specifically-sized subset of numbers in a sequence based on the current position in that sequence.
While navigating through the many pages of ...
88
votes
30
answers
9k
views
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 ...
23
votes
15
answers
3k
views
Code Golf: Pig Latin
Challenge:
Take a sentence of input of any length and convert all the words in that sentence to pig latin. If you do not know what pig latin is please read Wikipedia: Pig Latin.
Specifications:
...
26
votes
4
answers
2k
views
Code Golf: 2D Platformer
The Challenge
Reach the end of the level!
Bonus points if you hit each of the (C)oin blocks exactly 2 times.
Disallowed
Hard coding the command sequence in any way.
Your favorite "One character ...
10
votes
7
answers
893
views
Code golf: "Color highlighting" of repeated text
(Thanks to greg0ire below for helping with key concepts)
The challenge:
Build a program that finds all substrings and "tags" them with color attributes (effectively highlighting them in XML).
The ...
20
votes
7
answers
2k
views
Code Golf: Rotating Maze
Code Golf: Rotating Maze
Make a program that takes in a file consisting of a maze. The maze has walls given by #. The maze must include a single ball, given by a o and any number of holes given by a @...
25
votes
10
answers
5k
views
Code Golf: Zigzag pattern scanning
The Challenge
The shortest code by character count that takes a single input integer N (N >= 3) and returns an array of indices that when iterated would traverse an NxN matrix according to the JPEG "...
36
votes
14
answers
36k
views
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 ...
22
votes
13
answers
3k
views
Code Golf: Diamond Pattern
The challenge
The shortest code by character count to output a a pattern of diamonds according to the input.
The input is composed of 3 positive numbers representing the size of the diamond and the ...
22
votes
9
answers
3k
views
Code Golf: Phone Number to Words
Guidelines for code-golf on SO
We've all seen phone numbers that are put into words: 1-800-BUY-MORE, etc.
What is the shortest amount of code you can write that will produce all the possible ...
30
votes
17
answers
6k
views
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 ...
16
votes
15
answers
2k
views
File Fix-it codegolf (GCJ 2010 1B-A)
Last year (2009), the Google Code Jam featured an interesting problem as the first problem in Round 1B: Decision Tree
As the problem seemed tailored for Lisp-like languages, we spontaneously had an ...
26
votes
10
answers
3k
views
Code Golf: Code 39 Bar Code
The challenge
The shortest code by character count to draw an ASCII representation of a Code 39 bar code.
Wikipedia article about Code 39: http://en.wikipedia.org/wiki/Code_39
Input
The input ...
22
votes
6
answers
3k
views
Code Golf: Ghost Leg
The challenge
The shortest code by character count that will output the numeric solution, given a number and a valid string pattern, using the Ghost Leg method.
Examples
Input: 3,
"| | | | | | | |
...
13
votes
15
answers
2k
views
Code Golf: MSM Random Number Generator
The challenge:
The shortest code by character count that will generate a series of (pseudo)random numbers using the Middle-Square Method.
The Middle-Square Method of (pseudo)random number generation ...
27
votes
9
answers
13k
views
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 ...
40
votes
15
answers
4k
views
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(...
24
votes
7
answers
5k
views
Code Golf: Word Search Solver
Note: This is my first Code Golf challenge/question, so I might not be using the correct format below. I'm not really sure how to tag this particular question, and should this be community wiki? ...
22
votes
10
answers
2k
views
Code Golf: Easter Spiral
What's more appropriate than a Spiral for Easter Code Golf sessions? Well, I guess almost anything.
The Challenge
The shortest code by character count to display a nice ASCII Spiral made of ...
49
votes
16
answers
4k
views
Code Golf: Connecting the dots
You may remember these drawings from when you were a child, but now it's time to let the computer draw them (in full ascii splendour). Have fun!
Description:
The input are multiple lines (terminated ...
95
votes
26
answers
10k
views
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 ...
48
votes
23
answers
4k
views
Code Golf: Triforce
This is inspired by/taken from this thread: http://www.allegro.cc/forums/thread/603383
The Problem
Assume the user gives you a numeric input ranging from 1 to 7. Input should be taken from the ...
86
votes
70
answers
12k
views
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 ...
42
votes
35
answers
11k
views
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 ...
88
votes
22
answers
6k
views
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 ...
23
votes
12
answers
3k
views
Code Golf: Lights out
The challenge
The shortest code by character count to solve the input lights out board.
The lights out board is a 2d square grid of varying size composed of two characters - . for a light that is ...
26
votes
9
answers
2k
views
Code Golf: Diamond Blackjack
The challenge
The shortest code by character count to output a best-case blackjack hand from the list of number-cards given.
Input is a list of numbers from 1 to 10 (inclusive) separated by space.
...
27
votes
19
answers
5k
views
Code Golf: Ulam Spiral
The Challenge
The shortest code by character count to output Ulam's spiral with a spiral size given by user input.
Ulam's spiral is one method to map prime numbers. The spiral starts from the number 1 ...
16
votes
12
answers
4k
views
Turing Machine Code Golf
Ok guys, today's goal is to build a Turing machine simulator. For those that don't know what it is, see the Wikipedia article. The state table we are using today is found at the end of the Formal ...
53
votes
4
answers
3k
views
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, ...
37
votes
21
answers
5k
views
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 ...
51
votes
13
answers
5k
views
Code Golf: Hourglass
The challenge
The shortest code by character count to output an hourglass according to user input.
Input is composed of two numbers: First number is a greater than 1 integer that represents the ...
36
votes
15
answers
2k
views
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:
\_|_/
_/ \_
\___/
...
61
votes
13
answers
4k
views
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 ...
36
votes
12
answers
3k
views
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 ...
31
votes
14
answers
2k
views
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 ...
152
votes
28
answers
13k
views
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 ...