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

8
votes
2answers
69 views

Fond Memories of Past Primes

Consider a prime number p, written in base 10. The memory of p is defined as the number of distinct primes less than p that are contained as substrings of p. Challenge Given a non-negative integer n ...
14
votes
1answer
203 views

Who is the rightful ruler?

Who will rule the realm? You are given a family tree which contains: name, sex, date of birth, date of death and a list of heirs, for each family member. You may use any convenient (nested) list ...
16
votes
1answer
160 views

Convert Brainfuck to MarioLANG

MarioLANG is a two-dimensional programming language where the source code resembles a Super Mario Bros. level. Furthermore, its instruction set is very similar to Brainfuck's. This means that ...
31
votes
3answers
2k views

Enumerate valid Brainf**k programs

Golunar/Unary is a way to encode all valid Brainfuck programs, but it is not an enumeration, since most natural numbers do not correspond to a valid program. For the purpose of this challenge, assume ...
10
votes
4answers
198 views

A backwards relationship

Write a program or function that, given two ASCII strings A and B, will produce strings A' and B' where the common substrings are reversed in their place. The process for finding A' is as follows: ...
15
votes
6answers
865 views

Let's see some action!

Who doesn't love action movies with fast noisy cars, especially those with a lot of crashes? Who doesn't love action shots in ascii art? The scene is: Two cars are starting at opposite sides of a ...
9
votes
1answer
298 views

Solve a game of Accordion

Accordion is a solitaire card game I recently came across where nearly every layout is solvable, but incredibly hard. You can play it here. Rules 52 face cards are placed face-up in a random order. ...
20
votes
18answers
4k views

Stop, stand there where you are!

Challenge Write a function which takes one parameter: an integer t. Your function has to stop your program for t seconds before continuing, similar to time.sleep(t) in Python and WAIT t in BBC BASIC. ...
17
votes
1answer
218 views

Shapeshifting boxes

I define four box styles: +-----+ ooooooo ^^^^^ ******* | 1 | o 2 o < 3 > * 4 * | | o o < > * * +-----+ ooooooo vvvvv ******* Write a ...
37
votes
12answers
4k views

A naturally occurring prime generator

There are quite a large number of prime generating functions. Pretty much all of them are constructed and are based on the sieve of Eratosthenes, the Möbius function or the Wilson's theorem and are ...
11
votes
4answers
327 views

Approximate Square Formation

Background I have a bunch of square-shaped boxes of equal size, and since I'm a neat person, I want to arrange them all into a square formation. However, their number is not necessarily a perfect ...
8
votes
4answers
299 views

Number of domino tilings

Write a program or function that given positive n and m calculates the number of valid distinct domino tilings you can fit in a n by m rectangle. This is sequence A099390 in the Online Encyclopedia of ...
5
votes
0answers
309 views

Up 12 at 4 it's

Introduction On BBC Radio 2, on Saturdays there's a show hosted by Tony Blackburn called Pick of the Pops. Here, Tony selects a random week from a random year (in the range 1960-1989), and plays the ...
53
votes
11answers
2k views

Vertically collapse text

Say I have text like this (each word on one line, with no spaces) Programming Puzzles & Code Golf That makes no sense! It totally defies the laws of physics. Your challenge is to remedy this ...
7
votes
0answers
145 views

Can I make that shape with blocks, slabs, and stairs?

Consider a rectangular two-dimensional grid where each cell can either be empty (.) or full (0). e.g. ..00.... 0000.... .00000.. 000...00 ..000000 000.00.. The grid is considered infinite, all ...
14
votes
5answers
757 views

Fibonacci in +!()[]script

Write a piece of JavaScript code that calls alert with an array containing the first 50 Fibonacci numbers in order. You may only use the following characters: +!()[]. As a reference, your code must ...
6
votes
5answers
297 views

Distributing Numbers

In this challenge you'll be using be distributing a product over sums and differences of numbers, as explained here. Examples Input | Output -------------|------------- 23(12+42) | ...
6
votes
1answer
206 views

Computing the geometric median

Given a list of integer points in an n-dimensional space, output the geometric median. Note that the output is not necessarily integer. Your answer must be precise to at least two digits after the ...
4
votes
0answers
169 views

Check all the keys of a keyboard [on hold]

Write the shortest program that waits for every key of a Standard 101 key US Keyboard to be pressed at least once in any order and then exits writing OK! Every time a key is pressed the program ...
10
votes
0answers
243 views

Magic: the Gathering Combat Golf

Magic: the Gathering is a trading card game where, among other things, players play cards representing creatures, which can then attack the other player, or defend against the other player's attacks ...
-7
votes
7answers
177 views

Puzzle: Factor these 256-bit semiprimes [on hold]

Challenge Write a program to factor this set of 10 numbers: 15683499351193564659087946928346254200387478295674004601169717908835380854917 ...
8
votes
3answers
258 views

Zig-zag strings

Zig-zag strings Given a string and a positive integer, output the string in a zig-zag wave pattern with a peak amplitude and character spacing equal to the integer. This is similar to this question ...
-1
votes
0answers
54 views

Simultaneous Equation Solver [duplicate]

Solve linear simultaneous equations with up to 26 variables (a-z). Edit: This question is similar but different to the one posed here. This question is designed to take in more natural inputs, as ...
0
votes
0answers
52 views

Golf: Tabula Recta [duplicate]

From Chapter 18 of Significant Digits, a fan-fiction of the Harry Potter and the Methods of Rationality fan-fiction, we have the following cryptographic problem: As it happened, the books were ...
13
votes
23answers
2k views

Sign that word 2!

Sign that word 2! Not that long ago, I posted a challenge called Sign that word!. In the challenge, you must find the signature of word, which is the letters put in order (e.g. The signature of this ...
20
votes
6answers
987 views

Create rainbow text

Your challenge is to take input as a line of text and output it like this. Input / output The input will be a string that contains only printable ASCII characters. The first or last characters ...
15
votes
3answers
272 views

Toggle, Print, Repeat

This challenge is loosely inspired by the unimplemented esolang Pada. Consider an array of 8 bits, all initialised to zero. We'll introduce a very minimalistic instruction set to print arbitrary ...
10
votes
18answers
533 views

Finding the Value of Words!

Introduction In the land of [Insert cool name here], people don't buy things with money, because everyone has a severe allergy to paper. They pay eachother with words! But how is that? Well, they ...
27
votes
27answers
1k views

Twisting Words!

Twisting Words! Given a string and a positive integer. You must twist the string, back and forth. Example Input / Output Input Programming Puzzles & Code Golf 4 Output Prog mmar ing zzuP ...
9
votes
1answer
362 views
+100

Fixing a logic system

You are given a set of logic statements. Your challenge is to remove any ones that contradict the others, but in the optimal way (i.e. removing a minimal number of statements). Challenge You will ...
6
votes
7answers
676 views

Construct a polynomial with given roots

The challenge is to write the shortest function/program to find a polynomial given the roots. The function or program should take valid input; that is, a list of integers representing the roots of the ...
7
votes
2answers
270 views

Road painting ahead

Given two parameters lane pattern and road length, print an ASCII representation of the lane markings for Roads and Traffic Service to paint the roads. Example input/output Input: BTHMLRPHU, 21 I ...
20
votes
11answers
2k views
+50

The hue of a color

You are given the RGB values of a color. Your task is simple: to calculate the hue, in the simplest definition. Say the channels with highest, middle and lowest value are X, Y, Z (which are either ...
31
votes
5answers
1k views

Can you reach this number by doubling and rearranging?

Inspired by this question on Math.SE. Starting with 1 you can repeatedly perform one of the following two operations: Double the number. or Rearrange its digits in any way you want, except that ...
12
votes
41answers
4k views

Sign that word!

What is a Word Signature? The signature of a word are all of it's letters put in order - the signatures of this, hist and hits are all hist. The Challenge Write a program program should ask for an ...
4
votes
1answer
198 views

Switch program flow from external pulse

You work for the military as a coder and are responsible for writing software to control missiles. Your task is to write a program or function that will output a code sequence (any length ASCII ...
7
votes
3answers
434 views

ASCII Art Chessboard

In this challenge, you are to draw the chessboard below, and allow for moves to be made. 1. Drawing Each white square has 5x9 spaces. Each black square has 5x9 colons. The board is surrounded by a ...
6
votes
4answers
499 views

Let's play Hangman?

According to this page, the best strategy to guess English hangman words is to calculate the odds of each letter in a word list that meet our conditions. But, as I'm really lazy, I don't really want ...
140
votes
181answers
22k views

The Programming Language Quiz

Welcome to the Cops-and-Robbers edition of The Hello World Quiz! (If you've never played the quiz, feel free to try it out for a minute or 30. You don't need to have played it for this challenge ...
0
votes
0answers
71 views

Counting from 1 to an Integer… In Hexadecimal [duplicate]

Intro: This is a twist on a previous question of mine: Counting from 1 to an Integer... in Binary. Many of this question's rules and that question's rules are the same. Here is the intro from that ...
9
votes
1answer
380 views

Shortening a long number

When dealing with long numbers when code golfing, getting the length of your code down can be difficult, so do you have any tips for making a number shorter and easier to manage? For example, the ...
26
votes
3answers
2k views

Help, I'm trapped in an infinite factory!

This challenge is loosely inspired by the Zachtronics game Infinifactory. You are given a top-down view of a rectangular grid of conveyors, represented by >v<^. There may be cells without ...
17
votes
18answers
1k views

Tournament Format Synonyms

I spent all of today at a Super Smash Bros. tournament, and I started thinking about some of the terminology we use when describing sets. These are the three kinds of sets that I see played at ...
-2
votes
1answer
173 views

Ich ne know pas [closed]

Challenge You must write a program which correctly identifies the language a passage is written in. Rules The passage will be a string passed to your program either via STDIN or function arguments. ...
16
votes
9answers
662 views

Convert a Point of the Compass to Degrees

I came up with this challenge independently, but it turns out to be the inverse to this challenge by Doorknob. As I really like his spec, I decided to steal large parts of it instead of cooking up my ...
9
votes
8answers
490 views

Barcodegolf: Generate a number's UPC

Just about every store nowadays uses Universal Product Code (UPC) barcodes to simplify the checking out process. If the name doesn't mean anything to you, you will surely recognize what they look ...
13
votes
6answers
206 views

Prefix Tree Traversal

Write a program that takes in (via stdin or command line) a string with the recursive form PREFIX[SUFFIXES] where PREFIX may be any string of lowercase letters (a-z), including the empty string, ...
9
votes
10answers
378 views

Fill empty spaces by filling empty blanks

Write a function (such as placeAt) that takes an array of non-negative integers and an index that is a non-negative integer. It should place a 1 at the given index, possibly shifting other entries by ...
7
votes
2answers
255 views

Digitising the Library of Babel

The Library of Babel is defined as a universe in the form of a vast library containing all possible 410-page books of a certain format and character set. For the purposes of this question, ...
15
votes
4answers
539 views

ASCII Art Archery Arrows

Write a program or function that takes in a positive integer and prints or returns an ASCII art depiction of an archery arrow, scaled according to the input. If the input is 1 the output is /\ / ...