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

2
votes
0answers
97 views

Back to the future: Post-quantum cryptography

If you know your programming history, you may know that one of the earliest code golf challenges was to implement RSA encryption. Now, I'm challenging you to code golf an encryption system that is ...
-2
votes
0answers
54 views

Sing the Australian National Anthem - joyfully! [on hold]

We Australians have a pretty awful national anthem. Here it is in all its glory: To the tune of Advance Australia Fair Australians all let us rejoice, For we are young and free; We've golden ...
-4
votes
0answers
56 views

AIRPLANE SEATING PROBLEM [on hold]

An airlines company has several planes of the same type.Each plane has a seating capacity of 24 X 3 rows and 8 seats in each row split has shown. Hide Copy Code 1 [a] [b] [c] [d] [e] [f] [g] [h] 2 ...
16
votes
29answers
1k views

Comparing two numbers

Challenge Given two integers A and B as input, you must write a program which outputs if A>B, A==B or A<B. The integers will be in any reasonable range supported by your language which ...
10
votes
3answers
202 views

Possible Tetris sequences

Write code to figure out whether a run of Tetris pieces could be generated by the official Tetris algorithm. Fewest bytes wins. Official Tetris games generate the sequence of falling pieces in a ...
22
votes
6answers
3k views

Is the pizza fair?

This question is inspired by, and is the inverse of this one. Dennis (E), Doorknob (D), Martin (M) and Chris (C) have ordered a pizza. The rectangular pizza is divided into square pieces, each marked ...
19
votes
9answers
2k views

Dead code elimination

Dead code sits there doing nothing, staring at us knowing it will never be executed... but today we can take revenge. Specification The input will be a multiline string. Each line may either be an ...
3
votes
2answers
147 views

Interpreted Interpreter [duplicate]

Duplicate? I knew somebody must've done this before. Programming a programming language in itself is something that has interested me since I knew what a programming language was. So I thought I'd ...
32
votes
7answers
794 views

Zigzagify a String

Write a program (or function) that takes in a non-empty string of any printable ASCII characters. Print (or return) a zigzagging chain of the characters in the string with every neighboring pair of ...
36
votes
7answers
962 views

Dennis, Doorknob, Martin Büttner, Chris Jester-Young - Pizzeria!

Programming Puzzles & Code Golf is about to get a new moderator, Dennis! This challenge is a tribute to him and our other active (or recently active) moderators: Doorknob, Martin Büttner, and ...
66
votes
178answers
6k views

“Hello, World!”

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
25
votes
9answers
1k 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 strictly less than p that are contained as substrings of p. Challenge Given a non-negative ...
18
votes
1answer
309 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 ...
17
votes
1answer
207 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 ...
33
votes
4answers
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
223 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: ...
19
votes
13answers
1k 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
317 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. ...
21
votes
19answers
4k views
+50

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. ...
18
votes
1answer
237 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
328 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
301 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
317 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 ...
58
votes
13answers
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
159 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
777 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 ...
8
votes
10answers
453 views
+50

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
214 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
173 views

Check all the keys of a keyboard [closed]

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
251 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
184 views

Puzzle: Factor these 256-bit semiprimes [closed]

Challenge Write a program to factor this set of 10 numbers: 15683499351193564659087946928346254200387478295674004601169717908835380854917 ...
8
votes
3answers
263 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 ...
15
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 ...
21
votes
6answers
1k 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
284 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
539 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 ...
12
votes
2answers
419 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
680 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
275 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 ...
21
votes
14answers
2k views

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
6answers
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
445 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
503 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
198answers
23k views

The Programming Language Quiz

Notice: This challenge will close for further cop answers on 01/09/2015, 00:00:00 UTC. Any answers posted after that time will not be eligible for winning and will not be included in the ...