Code-golf is a competition to solve a particular problem in the fewest characters or bytes of source code. If source code length is not the primary scoring criterion, consider using another tag instead.

learn more… | top users | synonyms

6
votes
7answers
406 views

Display a tally (in varying bases)

Tallying is a simple counting system that works in base 5. There are various different tallying systems used around the world, but the one that is used in most English-speaking countries is perhaps ...
2
votes
2answers
162 views

Organise the Gregorian Church's Music [on hold]

The year is 930, and the Gregorian Church is having a problem. They have thousands of pages of chant music, but the problem is that all the sheet music was simply thrown onto a pile instead of having ...
6
votes
0answers
151 views

One source, lots of Brainfuck [duplicate]

Write a Brainfuck interpreter that can interpret multiple Brainfuck programs embedded within the same source. The syntax is the same except that the instructions must be prefixxed with the number/ID ...
7
votes
2answers
262 views

Write a program which replaces with spaces the braces in cases where braces in places cause stasis

You are a project manager. One day, one of your programmers went insane (not your fault) and took all the expressions in the codebase and added random brackets to them, before quitting on the spot, ...
6
votes
2answers
281 views

Put a list in order

With a window similar to the one pictured below, you are given a list of strings, which you want to put in alphabetical order. As shown, you have five operations: Move up [U] - moves the ...
3
votes
1answer
274 views

Output an Animated Trigonometry Circle

I want you to write a program that outputs a trigonometry circle like the one below. I also want you to animate this circle, having the sine line move along the circumference with the other lines move ...
13
votes
23answers
4k views

Output the legendary Yggdrasil

Your task is to output a representation of the legendary tree of life, Yggdrasil. You must write a program whose output is exactly that : /\ ...
4
votes
3answers
384 views

Standardise leading zeroes in an input string [on hold]

Write a program in the shortest number of bytes possible that will parse any string given to it by input, and output that string with any and all numbers padded with leading zeroes to match the ...
-8
votes
0answers
77 views

Produce “Happy Birthday” in output [on hold]

So, Like this code: print map(lambda x: "Happy Birthday to " + ("you" if x != 2 else "_name"),range(4)) that prints Happy Birthday in a geeky manner in python. Can anyone produce this type of ...
4
votes
3answers
296 views

The Forest Path

After your disastrous canoe ride, you ended up falling off a waterfall at the end of the river rapids. Your canoe exploded, but you managed to survive the explosion. However, your river journey went ...
14
votes
5answers
1k views

Run the Nth characters to get N

Write the shortest program possible such that when you combine the first character and every Nth character after it into a new program, the output is N. This must work for N = 1, 2, ..., 16. Another ...
23
votes
17answers
4k views

Find the Smoothest Number

Your challenge is to find the smoothest number over a given range. In other words, find the number whose greatest prime factor is the smallest. A smooth number is one whose largest prime factor is ...
-13
votes
1answer
181 views

print series from 1 to n which result in zero [on hold]

Write a program in any language that takes an input of any digit N (1<=N<=9) and prints all the possible series starting from 1 and ending in N with either "+" or "-" in between the digits so ...
14
votes
8answers
1k views

Extreme Whitewater Canoeing

You are paddling a canoe down a fairly fast whitewater river. Suddenly, your paddles explode, and you find yourself in a dangerous situation hurtling down a river rapid without any paddles. Luckily, ...
7
votes
3answers
286 views

Validate Loopy Solutions

This is an additional challenge to the generate Loopy puzzles challenge. You might want to solve this challenge before attempting the harder challenge in the previous link. The goal of this challenge ...
1
vote
0answers
185 views

Generate Loopy puzzles

Loopy is a puzzle game from the collection of Simon Tatham. The previous link contains a javascript implementation of a Loopy puzzle generator. I suggest everybody who wants to attempt this challenge ...
14
votes
2answers
417 views

Print ASCII Voxels

Write a program that reads a n x n x n array of binary values which represent an n*n*n cube, that consists of n^3 smaller cubes. Each value says whether there is a voxel (small cube) present in the ...
7
votes
4answers
291 views

Tuning Strings­

Task Write a program to determine the note sounded, along with how many cents out of tune, of a string tuned to a given frequency and pressed down at a given point. For the sake of simplicity, ...
7
votes
3answers
352 views

Codegolf: Quine and Antiquine

This challenge is similar to Can you Meta Quine? A quine is a program that produces itself on STDOUT. This challenge is to produce a program A which when run produces a program B on STDOUT. Program B ...
4
votes
1answer
111 views

In what base this string equals the following decimal value?

your task is... Given a string x and a positive integer y, to determine whether there is a positive integer b and an injective mapping from the distinct characters in x to the digits of base b which ...
3
votes
33answers
1k views

Input a number and return day of week

Not restricted to any one programming language. What I'm saying is you pass 1 to it and it returns Monday, 7 corresponds with sunday and so on. I've managed a 146 byte statement in Java to do the ...
18
votes
25answers
2k views

Reverse Bit Order of 32-bit Integers

Write the shortest code to reverse the bit order of a 32-bit integer. Rules: Input is assumed to be a valid integer or string equivalent if your language doesn't support numerical values (e.g. ...
0
votes
0answers
293 views

Is this the shortest possible Java quine?

Long ago, I found a Java quine online which uses a number of very clever tricks of the Java language (you can compile this at the command line, but it will not compile in most compilers--for obvious ...
12
votes
3answers
654 views

Expression that equals its length

Given a number, find an expression in words equaling that number, with a length of that number. Thus, to an input of 15, you might output sixteen minus one, which has fifteen characters (not counting ...
0
votes
0answers
97 views

Most expensive XAML code [closed]

While testing performance of various parts of my application, I came across the need to create XAML ballast that creates artificial performance bottleneck wherever I put it. For now, I am just ...
15
votes
2answers
493 views

DNA: Deoxyribonucleic ASCII

Given a sequence of the bases Adenine, Cytosine, Guanine and Thymine (encoded as ACGT), you're to produce an ASCII art representation of a corresponding double strand of DNA. The strand will extend ...
0
votes
1answer
130 views

Write a “Look-and-Say Numbers” generator [duplicate]

There is a sequence of numbers called the "Look-and-Say Numbers". Here is an example of the first 5 terms of the sequence, starting at 1 (with spaces added between the digits): 1 1 1 2 ...
8
votes
4answers
1k views
+300

How many trees in the Alphabet Forest?

Inspired by the connection rules from Calvin's Hobbies' question Make me an alphabet tree take a number of lines of letters as input and output the number of distinct connected trees it represents. ...
10
votes
4answers
428 views

Golf String's format() inverse

Invert the Format method. The Format method of the String class (or equivallent, such as sprintf) is available in most languages. It basically takes a "Format" string which may contain placeholders ...
4
votes
9answers
792 views

Stack a random number of cups into a perfect two dimensional pyramid (triangle)

You are given a certain number of cups (n). You are tasked with stacking these cups into a pyramid, with each row having one more cup than the row above it. The number you are given may or may not be ...
16
votes
7answers
1k views

An Ant on a Cube

An ant walks along the edges (not faces) of a wireframe cube. Each vertex it encounters presents it with a fork from which two new edges branch off. The ant chooses which way to turn -- left or right. ...
23
votes
5answers
1k views

Code that runs the Game of Life on itself

Write two rectangular blocks of code, each w characters wide and h characters tall, that implement Conway's Game of Life when arranged in a grid. (w and h may be any positive integers) For example, ...
15
votes
8answers
1k views

Draw the Stickman Wars

Picture of me drafting this challenge with my advanced drawing skills. Background The Stickman wars happened long ago, when Earth's dominant species was made of nothing but sticks. Historians ...
9
votes
1answer
202 views

Primality Testing in Manufactoria

Background Manufactoria is a game about programming. The player must use a form of two-dimensional programming language to complete tasks. If you've never heard of it, the easiest way to learn is to ...
12
votes
14answers
953 views

Check if a number is a product of consecutive integer numbers

Some numbers such as: 6, 12, 20, 30, 42, 56, 60, 90, 120 and so on as can be expressed as a product of consecutive integer numbers as shown below. 6 = 2 * 3 12 = 3 * 4 30 = 5 * 6 60 = 3 * 4 ...
13
votes
15answers
2k views

Output Graham's Number

Write a program that outputs all 64 layers of this representation of Graham's number from Wikipedia:    Your output must exactly match this ASCII version (in which ^ represents Knuth's ...
8
votes
7answers
709 views

is_gaussian_prime(z)?

Task Write a function that accepts two integers a,b that represent the Gaussian integer z = a+ib (complex number). The program must return true or false depending on whether a+ib is a Gaussian prime ...
12
votes
2answers
1k views

Congratulations on getting 10,000 reputation!

After @MartinBüttner achieved exactly 10,000 reputation, we now have three full rows of 10k users on the users page! Now, since we're all programmers here, we like to automate things instead of doing ...
11
votes
11answers
3k views

Make me an alphabet tree

Intro In most fonts all of the uppercase alphabet characters besides BDO have single lines approximately touching some of the four corners of the character's bounding rectangle: ...
51
votes
14answers
9k views

I HATE spaces in file names

It is simple. I cannot stand when people use spaces when naming files. It sometimes wrecks console commands and makes the output of ls ugly. The challenge is to write a program (only ascii ...
1
vote
10answers
906 views

Crop an image to a square

In this challenge, you will take an input image and crop it to make a square, leaving only the central part of the input image. The answers must work with landscape, portrait, or square input images. ...
2
votes
5answers
367 views

Create shortest log organizer

Create the shortest script that organizes all the logs by month and date. Rules Syntax organize <folder to scan> <folder to place logs> folder cannot be root the two folder should ...
1
vote
0answers
95 views

Push Button Probabilities [duplicate]

The Challenge The challenge is that I have a standard mechanical push button lock and you need to find out every possible code that could unlock it. With a standard mechanical push button lock you ...
15
votes
13answers
1k views

Determine a string's Scrabble score and validity

Your task is to determine if a given string is of proper length and can be represented with Scrabble tiles and, if so, output the sum of each letter's score. If you don't know how to play Scrabble:, ...
8
votes
5answers
692 views

Raise to the Power

Challenge Challenge is writing a program that takes a positive numbers a and a nonzero number b and outputs a^b (a raised to the power b). You can only use + - * / abs() as mathematical ...
3
votes
1answer
148 views

Calculate the Riemann Zeta Function [closed]

Calculate the Riemann zeta function to the maximum primitive precision in your language (for C-family, that would be double or long double, var in JS, etc.) No need for BigDecimal or the like unless ...
25
votes
10answers
4k views

Golf a Venn Diagram generator

Golf a Venn Diagram generator In order to properly celebrate John Venn's 180th birthday, today your task will be creating a program that outputs a Venn Diagram! Input: A positive integer N that ...
3
votes
3answers
365 views

Compress and Decompress sentence using vowel based encryption cipher [closed]

The aim is to parse a sentence and compress/encrypt it according to the rules below and then decrypt it using the key: Remove all letters in a word before the first vowel is encountered. Example: ...
18
votes
2answers
2k views

Fill the Screen with Wang Tiles

It has been proven that the following 13 square Wang tiles always tile the plane aperiodically. This means that when the squares are arranged in a grid with all neighboring sides the same color, a ...
20
votes
22answers
3k views

Program your favorite phrase

Pick a quote or phrase that is exactly 5 words long, such as Programming puzzles and code golf!. Write a program that, when appended to itself n times, outputs the first n + 1 words of your phrase in ...