Code-golf is a competition to solve a particular problem in the fewest bytes of source code. If you want to score by characters instead of bytes, state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

learn more… | top users | synonyms

9
votes
6answers
267 views

Compute the Hausdorff Distance

Introduction The Hausdorff distance measures the difference between two subsets of a metric space. Intuitively, a metric space is just some set with a built-in distance function; in this challenge, ...
14
votes
0answers
142 views

Stringing a Pearl Necklace

Overview Pearls (or Masyu) is a logic game played on a grid. There are black and white pearls placed on the grid. The object is to form a single, closed loop that travels through each pearl using ...
11
votes
3answers
222 views

Tiling a 2^N by 2^N Grid with L-Shaped Trominoes

When students are first taught about the proof technique of mathematical induction, a common example is the problem of tiling a 2N×2N grid with L-shaped trominoes, leaving one predetermined grid ...
34
votes
23answers
2k views

Telescopic Parentheses

Consider a non-empty string of correctly balanced parentheses: (()(()())()((())))(()) We can imagine that each pair of parentheses represents a ring in a collapsed telescopic construction. So let's ...
17
votes
8answers
2k views

Who wins a Spades trick

Write code to determine who wins a four-card trick in a game of Spades. Fewest bytes wins. The input is a string that lists the four cards played in sequence like TH QC JH 2H (Ten of Hearts, Queen of ...
24
votes
4answers
1k views

Code Explanation Formatter

Successful code golf submissions are, by nature, filled with crazy symbols all over the place. To make their submission easier to understand, many code-golfers choose to include an explanation of ...
1
vote
2answers
273 views

Write an Antiquine [on hold]

Definitions: I define a "true antiquine" as follows: A true antiquine is a non-empty computer program of length n which takes no input and produces a copy of every valid program of length n in ...
16
votes
3answers
280 views

Group Therapy: Identify Groups

Write a program, that determines whether the multiplication table of the given finite magma represents a group. A magma is a set with a binary operation that is closed, that means for all a,b in G, ...
-1
votes
2answers
135 views

Java Package Correction

I have a lot of java projects and I am often making new ones. I have a few helper classes (Vector, Logger, etc.) and it takes a lot of time correcting the first line to the correct package, I would ...
-1
votes
1answer
112 views

Find unique, sorted, dot+alphanumeric strings in a file not beginning with a digit/dot, not ending in dot

Write a script that can take a single pathname of a file, read it, and output the sorted, unique strings within it such that: each string begins with a letter (a-z, A-Z) all characters between the ...
6
votes
1answer
247 views

Write a Shift Interpreter

EDIT: As some of you suspected, there was a bug in the official interpreter: the order of composition in . was reversed. I had two versions of the interpreter, and used the wrong one here. The ...
7
votes
14answers
743 views

Minimum base to count to a string

The Challenge Input: alphanumeric string. You can assume that the string will only contain the characters [0-9A-Z]. This can come from a parameter, command line, or STDIN. Digits are always before ...
29
votes
13answers
3k views

Draw a Random ASCII Art Quilt

For this challenge, an ASCII art quilt will be a block of text 24 characters wide and 18 lines tall, containing the characters =-<>/\ in a quilt-like pattern that is horizontally and vertically ...
12
votes
1answer
455 views

Two-zero-one-five puzzle

Background This puzzle is a variation on the four fours puzzle (itself the topic of a past question). Like that puzzle, the aim is to find mathematical expressions for different whole numbers, using ...
39
votes
6answers
9k views

Hodorize a String

Hodor is a slow-minded but endearing character on the show Game of Thrones (he's in the books as well of course). The only word he ever says is 'hodor'. Surprisingly, despite not having much of a ...
7
votes
0answers
178 views

Meta quine checker

This challenge, if you accept it, is to write three functions or programs A, B, and C: A is a quine that outputs all of A,B and C (which is also the whole content of the code in your submission). B ...
1
vote
1answer
79 views

Write two single line functions to encode and decode base64 [duplicate]

Write two functions of one line each that can encode and decode base64. Use any language you want, but if the language can naturally be converted to a single line (e.g. javascript) then any block of ...
5
votes
1answer
161 views

The Gray area of n-ary codes

Write a program or function that takes a base n and a number x, and returns or outputs the n-ary Gray code of x. Rules n is an integer in the range 2 <= n <= 16. x is an integer in the range ...
18
votes
3answers
329 views

Reaching one's lucky numbers in reputation

A new code-golfer, Joe, just registered to the site. He has 1 reputation but determined to reach all his lucky numbers in reputation exactly. Joe believes in higher powers which will help him to ...
10
votes
2answers
190 views

Tips for golfing in The Shakespeare Programming Language

What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL ...
18
votes
11answers
2k views

Output a Face on a Numbered Cube

Assign the numbers 0 through 7 to the 8 vertices of a cube in any way you want. Exactly one number must be assigned to each vertex. For example, your vertices might be assigned like this: ...
22
votes
1answer
421 views
+100

Optimal Games of Tic Tac Torus

This challenge is about the game Tic Tac Toe, but it's played on a torus. How to play To create the necessary game board, you start out with a regular Tic Tac Toe game board. First fold it into a ...
3
votes
0answers
96 views

Solving a Jigsaw Puzzle!

I've just bought a new jigsaw puzzle but, as a programmer, I'm too lazy to do it by myself. So I've devised a way to encode the pieces, and now I need a way to solve the puzzle itself. Challenge A ...
23
votes
2answers
342 views

Connecting letters

You should write a program or function which receives a block of chars represented as a string and outputs or returns a similar string in which the letters adjacent in the alphabet are connected. A ...
15
votes
17answers
3k views

Calculating (3 + sqrt(5))^n exactly

Today your goal is to find integers a and b given non-negative integer n such that: You should write a program or a function that takes parameter n and outputs a and b in a format of your choice. ...
9
votes
3answers
191 views

IMP: Implicit multiplication parser

Jack likes C programming language, but hates to write expressions like V=a*b*h; to multiply the values. He would like to write V=abh; instead, why should compiler moan about abh symbol being ...
10
votes
3answers
208 views

Wrap-Around Subsequences

Introduction In this challenge, your task is to find generalized subsequences of strings. The subsequences are not necessarily contiguous, and they can also "wrap around" the string, going past its ...
0
votes
0answers
117 views

Generate net puzzles

An acyclical grid is a mapping of an acyclical graph (that is, a tree) where each node has no more than four edges onto a toroidal rectangular grid such that each cell of the grid is occupied by a ...
-1
votes
0answers
59 views

write the shortest code to print a diamond shape [duplicate]

write the shortest code in c++(other languages are also welcome) using only standard library, which will: ask for a value, which will be the size of the diamond shape. print the diamond shape, ...
18
votes
1answer
346 views

Programming Tetris Blocks (Literally)

In the game Tetris, there are 7 types of bricks or Tetriminoes, which are mathematically known as tetrominoes because they are all made with 4 square segments: The have the names I, J, L, O, S, T, ...
11
votes
10answers
539 views

Cops and Robbers

Everyone always wants to implement Conway's Game of Life. That's boring! Let's do cops and robbers instead! You'll have two teams: the cops and the robbers. Each team has 5 members with 50 health ...
19
votes
9answers
2k views

Generate a pair of integers from a non-negative one

You should write a program or function which takes a non-negative integer N as input and outputs or returns two integers (negative, zero or positive) X and Y. Integers are meant in the mathematical ...
12
votes
2answers
189 views

ASCII L-system renderer

Background An L-system (or Lindenmayer system) is a parallel rewriting system that, among other things, can be easily used to model fractals. This question concerns deterministic, context-free ...
7
votes
3answers
260 views

Nameless to Brainf**k converter

This is inspired by the Brainf*** to tinyBF converter challenge. Brainf**k (which will be henceforth referred to as BF) is a well-known estoric programming language, so I won't go over it too much ...
9
votes
1answer
220 views

Slime Molds Can Count!

Background Slime molds are awesome. If you place them on a surface with food sources, they will spread their tendrils to find the food, after which they form a network of connections between the ...
60
votes
21answers
5k views

Interpreting Fish (no, not that Fish)

Consider these five ASCII art sea creatures: Standard fish: ><> or <>< Speedy fish: >><> or <><< Sturdy fish: ><>> or <<>< Stretchy ...
5
votes
5answers
301 views

Brainf*** to tinyBF converter

You don't need to know these languages to participate. Every necessary info is in this question. You should write a program or function which given a brainfuck (BF) code as input outputs its tinyBF ...
16
votes
15answers
979 views

Generate MathJax for the Golden Ratio Continued Fraction

In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered ...
13
votes
6answers
355 views

Out-of-Control Rounding Errors

Background You have recently been hired by a small accounting firm. The world of accounting is somewhat foreign to you, so you're not sure whether you are following all the professional guidelines. ...
29
votes
3answers
2k views

ASCII Doodling: Laser in a Box

Sometimes when I'm doodling, I draw a rectangle, start with a diagonal from one of the corners, and then just trace out a line by "reflecting" it whenever I hit a side of the rectangle. I continue ...
15
votes
1answer
379 views

Prepare to… die?

Background One source of ennui in tabletop role-playing games is dealing with rolls involving many dice. Casting a Disintegration spell may be instantaneous, but rolling and adding together 40 dice ...
10
votes
4answers
321 views

The Sound of Words

People have written many things allowing one thing to be visualized as another. Now I propose being able to translate letters to music! Its your job to write a program that takes a text file and ...
27
votes
11answers
2k views

Official Ruby Inspector

Here is a simple ASCII art ruby: ___ /\_/\ /_/ \_\ \ \_/ / \/_\/ As a jeweler for the ASCII Gemstone Corporation, your job is inspect the newly acquired rubies and leave a note about any ...
-2
votes
1answer
98 views

Compare array of decimal sum of Integers and exact fractional part

Develop a program which takes two arrays of decimal numbers, and compare the sum of whole numbers only and the decimal part. If the sums of the whole numbers are the same, and the decimal parts of ...
7
votes
4answers
389 views

The Partition Problem - Sorting Stacks of Boxes

Just last night I was reading a book which had a chapter on the Partition Problem; the Partition Problem is basically about splitting a set of numbers into two smaller sets of equal size. To ...
8
votes
5answers
308 views

Decide existence of total orderings

In this task, we consider arrays of positive integers such as this: 3 18 321 17 4 4 51 1 293 17 The input comprises a pair of such arrays both of arbitrary, possibly distinct, positive length. ...
-1
votes
4answers
87 views

Detect the main order based on sub-lists [closed]

The question is simple but the answer maybe not! suppose that you have the following lists that all of them are ordered (not consecutive): x = ['one', 'two', 'four'] y = ['two', 'three', 'five'] z ...
15
votes
6answers
649 views

Overlapping circle

You should write a program or function that given an N by N equally spaced square grid and a solid inscribed circle outputs or returns the number of grid squares which are overlapped partially or ...
5
votes
2answers
167 views

Tips for golfing in whitespace

What general tips do you have for golfing in Whitespace? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Whitespace (e.g. "remove ...
12
votes
4answers
520 views

Is the word typeable with keys adjacent to each other?

Before reading this I suggest reading this little puzzle: http://puzzling.stackexchange.com/questions/11408/longest-word-with-adjacent-letters-on-a-keyboard I want you to make a program that takes ...