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

8
votes
2answers
408 views

Syllabify English words - kind of

You're tasked with writing a program that syllabifies words in a string of text, by separating them with a hyphen. That would be a lot of work, so you want to skip some parts, mainly because you don't ...
-2
votes
0answers
108 views

Populating the screen with cubes [on hold]

The challange is simple, you must draw 125 equal cubes on the screen in the shape of a huge cube. To be more precise x,y,z of the cubes should be the ones obtained from this python code (or multiples ...
8
votes
1answer
127 views

Draw a Permutation Path

Imagine the following diagrams as sets of vertical criss-crossing tubes. 1 2 1 2 1 2 3 4 \ / \ / \ / \ / X | | | / \ / \ / \ / \ 2 1 1 2 | X | \ ...
4
votes
0answers
160 views

StackExchange Mustafa can't stand to be asked the same question three times

Austin: "Who sent you?" Mustafa: "You have to kill me!" Austin: "Who sent you?" Mustafa: "Kiss my ass, Powers!" Austin: "Who sent you?" Mustafa: "Dr. Evil." (...) ...
8
votes
2answers
269 views

Calculate to how many cubes one cube can be cut

Imagine some cube which we can cut into smaller cubes without remaining pieces. Find to how many cubes a cube can be cut. For example, a cube can be cut into 8, 27 (obviously 3rd powers of integers) ...
-5
votes
0answers
67 views

Make a line editor [on hold]

A line editor is a type of text editor in which you edit a file one line at a time. If you've used ed you know what this is. This line editor prompts* for a command, which is then run. Your job is ...
6
votes
0answers
190 views

Golfing for Domino Day

Given a setup of dominoes your task is to figure out which dominoes fall and which don't. Input Take a rectangular ASCII representation of a domino setup. The following characters are used for the ...
11
votes
1answer
343 views

Make me a window manager!

I hate code bloat! So I have decided to replace my Windows 7 system by a golfed version. However, I know that it is not easy, so let's build a prototype first. It will take a list of windows from the ...
11
votes
8answers
2k views

Write program which verifies Erdős–Straus conjecture

Write program, which verifies Erdős–Straus conjecture. Program should take as input one integern (3 <= n <= 1 000 000) and print triple of integers satisfying identity 4/n = 1/x + 1/y + 1/z, 0 ...
20
votes
3answers
1k views

Draw the Hilbert curve using slashes

The Hilbert curve is a space filling fractal that can be represented as a Lindenmayer system with successive generations that look like this: Thanks to ...
15
votes
2answers
591 views
+200

Where does the laser go?

Take a 2-dimensional grid and draw a number of line segments on it to represent mirrors. Now pick a point to place a theoretical laser and an angle to define the direction it's pointing. The question ...
5
votes
5answers
300 views

Permutation Numbering

The Challenge For a given set of n integers, write a program which will output its lexicographic index. The Rules The input must only be a set of unique non-negative integers separated by spaces. ...
9
votes
23answers
2k views

Generate me some appropriate license plates!

The scenario: You are a software designer working for a gov't-run company that designs license plates for cars and other vehicles. You've been asked to develop software that generates license ...
35
votes
8answers
2k views

ASCII Train Golf

Consider these seven ASCII train cars. Engine (E) __ ====== \/ | [] |========= | ) ================ O-O-O O-O-O \\ Passenger car (P) =============== | [] [] [] ...
6
votes
9answers
698 views

Calculate a rock rolling down a hill

Introduction Sisyphus was having some troubles at work lately. It seems he just never gets anything done, and he would love to find a solution to this problem. His current employment requires ...
5
votes
2answers
260 views

Courier Ception

Courier Ception The program must accept any string as input and output an pixel image that shows the input string in Courier. All the letters that contain a 'hole' (like abdegopqABDPQR etc) that is ...
12
votes
9answers
909 views

There is water on my window

The scenario I drive along a road with my car and it begins to rain. The raindrops are falling on my window randomly and now i ask myself, where is the biggest connected wet area? The task To make ...
12
votes
10answers
994 views

Output the answer above yours

Write a program that outputs the contents of the first HTML <code>...</code> block of the answer to this question that is just above yours when the answers are sorted by votes. Output Top! ...
8
votes
1answer
487 views

Who wants to be a Kolmogorov complexity winner?

You mission today is to invent a text compressor. Task You'll write two functions: The packer is a function that accepts a string of ASCII characters (U+0000 to U+007F) and outputs a Unicode ...
37
votes
41answers
5k views

Rock Around the Clock

In as few Unicode characters as possible, print the following (144 characters): 1, 2, 3 o'clock, 4 o'clock rock, 5, 6, 7 o'clock, 8 o'clock rock, 9, 10, 11 o'clock, 12 o'clock rock, We're gonna rock ...
15
votes
1answer
648 views

Find a route between two Wikipedia articles

Introduction Recently, I was skyping with a bunch of friends and we got bored and had nothing to do, so we "invented" a "game" (some people in the comments pointed out that this game is playable ...
7
votes
0answers
84 views

Checking periodic table words [duplicate]

Given a sequence of letters, write a program to construct it using symbols on the periodic table. For example, given the input bacon, the program should output: BaCoN BAcON BaCON Note that ...
6
votes
5answers
446 views

Output nth term in Catalan type sequence

Given a number, starting with 1, create new numbers (children) by taking the last digit, n, and concatenating 1 through n+1. This seems to be a much better explanation of the sequence A071159. ...
12
votes
3answers
643 views

ASCII Waterworks

Intro Consider a grid of the characters f A\/ such as f f f A A / \ \ / A A \/ / \/ where: f represents a faucet that pours a stream of water downward ...
1
vote
0answers
122 views

Recover a bzip2 file

The popular .bz2 compression format is used to store all sorts of things. One of the more interesting features is that it consists of several independently decompressible blocks, allowing recovery of ...
3
votes
4answers
387 views

Difference of expressions when evaluated in different orders

We all know the standard order of operations for math functions (PEMDAS), but what if we instead evaluated expressions left-to-right? The Challenge Given a string through standard input or through ...
7
votes
5answers
466 views

Spiral in the grid

Write a program which enumerates points on a regular grid in the form of a spiral. The output should be the indices of the points (row-major) and the spiral should start at 0 and proceed ...
17
votes
5answers
805 views

Check if three letters can form a “Godel-Escher-Bach cube”

This question is inspired by the cover of the book "Godel, Escher, Bach": The challenge here is to write a function that tells if three given letters can produce a 3D sculpture that can be read ...
19
votes
0answers
687 views

Print the lyrics to “Twinkle Twinkle Little Star”

Your goal is to print the lyrics to the song "Twinkle Twinkle Little Star" as each note is played. The computer's microphone will hear notes. If the pitch (but not necessarily the length) of the note ...
5
votes
2answers
438 views

Crosswalk Efficiency

A standard road intersection contains 4 sidewalk corners and four crosswalks connecting them. It could also have 2 diagonal walks. sRRRRs iOOOOi dAAAAd eDDDDe side0----1walk ROAD|\ ...
-2
votes
0answers
106 views

Implement the Sieve of Eratosthenes [duplicate]

The task is simple. Create a program or function that will generate, and print, primes using the Sieve of Eratosthenes. The Sieve of Eratosthenes is known to be the most efficient way to find ...
15
votes
12answers
3k views

Simulate Rule 110

Rule 110 is a cellular automaton with some interesting properties. Your goal is to simulate a rule 110 in as few characters as possible. For those who don't know, rule 110 is simulated line by line. ...
7
votes
7answers
342 views

List the combinations of elements in a set [duplicate]

Given a set of n elements, the challenge is to write a function who lists all the combinations of k elements of in this set. Example Set: [1, 7, 4] Input: 2 Output: [1,7], [1,4], [7,4] Example ...
0
votes
2answers
258 views

Solve this math problem in smallest amount of code [closed]

Here I found a cool math problem. I thought you could write some golfed code to compute all answers between x and x.(there is an infinite amount). Problem: Once upon a time, and old lady went to sell ...
9
votes
0answers
422 views

Build a MU puzzle solver

The MU puzzle is a puzzle in which you find out whether you can turn MI into MU given the following operations: If your string ends in I, you may add a U to the end. (e.g. MI -> MIU) If your ...
11
votes
2answers
516 views

Introspective Programming: Code that analyzes its source and its output

Write a program that outputs the total number of characters and the frequency of each character in its source and its output. You must follow the format illustrated in the example. Example If your ...
5
votes
5answers
429 views

Operations on Sets

Note: I have accepted an answer, but I'm willing to accept a better answer if it comes. Write a program that computes operations on sets. You may take input either from standard input or from command ...
-3
votes
2answers
177 views

Find the unique number [closed]

I have read a question similar to this. I found it interesting, And difficlut so I rephrased the question as a code golf. (that question is closed ) In 1 million and 1 numbers, all the numbers having ...
7
votes
4answers
508 views

Basic Algebraic Expansion

Problem I've got a GREAT new program that will change the way we think about math in computing, taking in strings of algebraic functions and doing AMAZING things with them! The only problem, is that ...
15
votes
34answers
2k views

Domino function

Using as few amount of Unicode characters as possible, create a function that receives three integers: Total amount of dominos nth affected domino Knock over direction (0=left, 1=right, or use ...
8
votes
3answers
791 views

Compact coding of integer into bitstring

I want to compactly code positive integers x into bits, in a manner allowing decoding back into the original integers for a stateless decoder knowing the maximum value m of each x; it shall be ...
36
votes
13answers
4k views

Write a Rectangular Program that Outputs the Number of Times it was Rotated

The title says it all. Your goal is to write a program that forms a w×h rectangle of characters that can be rotated and re-run to output the number of 90° Counter-Clockwise (CCW) rotations that have ...
5
votes
1answer
258 views

Probability to win a hand of poker (Texas hold 'em)

Challenge: In the last stage of a two players Texas hold 'em, given a two-card hand and five cards on table, determine your probability to win versus an opponent by the standard ranking of poker ...
17
votes
13answers
3k views

One Bad Ternary Operator Deserves Another

Today's Daily WTF quotes the following line of code... FailSafe==0?'No technical ...
-1
votes
3answers
154 views

Output a non-Context-Free Language [closed]

Your challenge is to write a program which will output a non-context-free language. A Context-free Grammar is a series of replacement rules, describing which symbols can be replaced by which other ...
180
votes
7answers
16k views

Draw with your CPU

I have come across an article where students used network traffic to draw their university on the country's IPv6 graph. [image] Your goal is simple to tell, but hard to implement. Draw the text MAIL ...
73
votes
14answers
8k views

Has my milk expired?

Aww, man, this expiry date doesn't write the months with letters! I can't tell if it's expiring on March 10th or October 3rd... Wait, no, never mind, the year says 2012. (alley-oops half-used brick of ...
4
votes
3answers
725 views

Brainfuck Sorting

Write a program in brainfuck that accepts input of 4 ASCII characters as numbers (from 32 to 126) and outputs the numbers or ASCII equivalent sorted in ascending order. Requirements: Your program ...
5
votes
1answer
251 views

Golfed sort by debian version number

I wrote some perl to sort by debian package version number (specification here). Whilst readable, it was disappointingly long (114 lines, 2042 characters) - shocking. So this challenge is to produce ...
10
votes
5answers
484 views

Reduce html to n characters while keeping the formatting

Almost every language has a built-in function that can split a string at a given position. However, as soon as you have html tags in the string, the built-in function will not work properly. Your ...