A code challenge is a competition for creative ways to solve a programming puzzle with an objective winning criterion not covered by other scoring tags (e.g. code-golf).

learn more… | top users | synonyms

63
votes
23answers
5k views

2016 Time Capsule String: How Versatile Is Your Language?

About a year ago on Dec 31, 2015, I had the idea that: We should make a time capsule string. Everybody gets to add one character and next new years we'll see who can make the best program out of ...
32
votes
20answers
6k views

Holy Hole In A Donut, Batman!

Some characters are more holy than others. Using as few unholy letters as possible, display the statement above. Challenge Write a full program to print Holy Hole In A Donut, Batman! to STDOUT or ...
22
votes
10answers
1k views

2016 Time Capsule String: Climb The Integer Ladder

Using the 74 characters from the 2016 time capsule string H@~*^)$.`~+1A|Q)p~`\Z!IQ~e:O.~@``#|9@)Tf\eT`=(!``|`~!y!`) Q~$x.4|m4~~&!L{% write N code snippets all in the same language where: The ...
13
votes
1answer
437 views
+200

Quine that takes as input the name of a language and outputs the same thing implemented in the input language

From Quine central: Write a quine that takes as input the name of a language and outputs the same thing implemented in the input language. The source article has something you can work from, but as ...
7
votes
1answer
310 views

Combinator quines

Background You have just learned what combinatory logic is. Intrigued by the various combinators you spend quite a bit of time learning about them. You finally stumble upon this particular expression:...
40
votes
14answers
7k views

What's the shortest contiguous subset of ASCII you need to output the rest?

The printable ASCII characters (hex codes 20 to 7E) in order are: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ (Note that space is in ...
15
votes
2answers
827 views

A game of atomic proportions

Your task make a bot that plays Atomas, with the highest score. How the game works: The gameboard starts with a ring of 6 "atoms", with numbers ranging from 1 to 3. You can "play" an atom between ...
147
votes
107answers
13k views

What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?

I think the question as above is clear, but just in case: Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline. Qualifying ...
5
votes
1answer
157 views

Shrink your language's character set [duplicate]

We often get restricted-source questions here on PPCG that favour submitting solutions using only a subset of characters (sufficiently so that there's a tag printable-ascii that identifies a ...
85
votes
72answers
16k views

Largest Number Printable

Before opening this I've done a little search and I've found there is a similar question, but it has been closed because it was ambiguous. I hope this won't. So, your goal is to write a program that ...
20
votes
7answers
563 views

Print Polyglot Pieces

Typically, polyglots are constructed in such a manner that each language can ignore parts of the code that are present for other languages, by wrapping them in string literals, using comment syntax, ...
35
votes
14answers
2k views

What will you bring for Thanksgiving?

Thanksgiving in the United States is coming up on November 24th. Many people will have a large dinner with their families, traditionally including turkey and many side dishes. This typically means the ...
0
votes
4answers
733 views

Theoretical algorithm to compute Graham's number

Graham's number G is defined in that way: 3^n = 3*..n times ...*3 3^^n = 3^(3^n) 3^^^n = 3^^(3^^n) 3^^^^n = 3^^^(3^^^n) g1 = 3^^^^3 g2 = 3^^...g1 times^^3 g3 = 3^^...g2 times^^3 ... G = 3^^...g63 ...
7
votes
4answers
368 views

Busy Brain Beaver reboot [duplicate]

Introduction I found a really interesting puzzle it was called Busy Brain Beaver. But it has been 3 years since the latest activity and there are some things I didn't like about it. So I decided to ...
-2
votes
0answers
83 views

The largest number you can, in a tweet [duplicate]

With 140 bytes or fewer (Twitter counts by characters but for consistency with other questions I'll use bytes), write a function that takes no arguments and returns the largest finite integer you can. ...
17
votes
2answers
672 views

Piet (Mondrian)'s Puzzle

For more information, watch this video, and go to A276523 for a related sequence. The Mondrian Puzzle (for an integer n) is the following: Fit non-congruent rectangles into a n*n square grid. What ...
7
votes
2answers
701 views

Project Euler Problem 12: optimize memory usage

I am referring to Project Euler #12. Write the solution in any language you want, but consume the least amount of memory while executing. Running time is not measure in this case. The sequence of ...
135
votes
0answers
5k views

Build a working game of Tetris in Conway's Game of Life

Here is a theoretical question - one that doesn't afford an easy answer in any case, not even the trivial one. In Conway's Game of Life, there exist constructs such as the metapixel which allow the ...
29
votes
3answers
1k views

Radiation Hardened Quine

As you should (hopefully) know, a radiation hardened quine is a quine that you can remove any one character from and still print its original, pre-modified source. The thing is, with most of these you ...
57
votes
6answers
4k views

Fault-Tolerant Hello World (a.k.a. the Interview)

At the end of your interview, the Evil Interviewer tells you, "We make all of our applicants take a short coding test, to see if they really know what they are talking about. Don't worry; it's easy. ...
21
votes
13answers
2k views

Keep the unique characters down

It's very simple: Your program or function should generate the following text: Elizabeth obnoxiously quoted (just too rowdy for my peace): "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG," giving me a ...
37
votes
8answers
6k views

Build a random number generator that passes the Diehard tests

While there are many code golf questions on here involving randomness, I haven't seen one yet that actually asks for building an algorithmic pseudorandom number generator. There's this one that asks ...
89
votes
27answers
9k views

What are the five most powerful characters in your language?

Choose any five characters your language supports. There are 5! = 5×4×3×2×1 = 120 ways these can be arranged into a 5-character string that contains each character once; 120 ...
4
votes
3answers
328 views

Quine permutation group

Write a program or function which, when run, outputs another program or function which is valid in the same language as the original program, and which itself will output another program or function ...
72
votes
31answers
7k views

The versatile integer printer

Write a piece of code that is executable in at least three different languages. The code must output the integer 1 in language number one, 2 in language number two, 3 in language number three etc. ...
16
votes
2answers
362 views

Chuck Norris vs Travelling Salesman

Introduction Almost everyone is familiar with the Travelling Salesman Problem (TSP). The task is to, given a list of N cities, find the minimum Hamiltonian cycle which is to say the shortest path ...
17
votes
6answers
1k views

Travelling Salesman

You are given, as a list or vector or whatever, a bunch of 3-tuples or whatever, where the first two things are strings, and the third thing is a number. The strings are cities, and the number is the ...
10
votes
9answers
520 views

Multi-lingual Challenge

After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages? Your answer needs to accept boolean input b and output the ...
0
votes
0answers
79 views

What path will santa take? [duplicate]

Question Santa must get to every house in the world to deliver gifts, can you make a program that will calculate the shortest path that Santa could take, and still visit all the cities listed? ...
7
votes
2answers
144 views

Create a version series

The Definition Given an integer x, a version series is a set of digits (base 10) from which any x-length subset of consecutive members is unique compared to all other possible subsets of the same ...
274
votes
14answers
52k views

Build a Compiler Bomb

Introduction You're probably familiar with zip bombs, XML bombs, etc. Put simply, they are (relatively) small files which produce enormous output when interpreted by naïve software. The challenge ...
17
votes
1answer
366 views

Make a regex polyglot

Write a regex that works in at least 2 regex flavors (or versions), and match a different string in each flavor (or version) it is running in. The strings to be matched in this challenge are the ...
24
votes
6answers
2k views

Big big numbers

Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible. Now I know the best way to do that: I'll be getting you to be writing this program. ...
46
votes
6answers
5k views

1 character typo generating most error messages from C++ compilation

It seems that simple changes to a C++ file, especially with templates, can generate pages of errors. This contest is to see what the largest "bang of the buck" is, that is the more verbose error ...
12
votes
7answers
745 views

Make a long type signature

Challenge Find an expression, at most 100 bytes long, with the longest type signature. Rules Any statically typed language with type inference is allowed The type must be non-ambiguous, but ...
30
votes
9answers
2k views

Uniquely separated pixels

For an N by N image, find a set of pixels such that no separation distance is present more than once. That is, if two pixels are separated by a distance d, then they are the only two pixels that are ...
8
votes
19answers
606 views

Maximizing output from minimal input

Obviously, code golfing is all about making the most of the least code. Who really cares what the actual output is? While we have had a challenge for highest input-to-output ratio, this is a call for ...
31
votes
0answers
1k views

Build a fewest-moves freecell solver

In the game of Freecell, you are tasked with building four foundation piles in suit from ace to king, on a layout where you build downward in alternating colours. However, you can only build one card ...
9
votes
3answers
828 views

Matrix property X revisited (or the Joy of X)

This challenge is partly an algorithms challenge, partly an optimization challenge and partly simply a fastest code challenge. A T matrix is fully specified by its first row r and first column c. ...
9
votes
4answers
250 views

Abstract Syntax Tree Golfing: FizzBuzz, Python

Summary Implement FizzBuzz in Python, with the fewest possible tokens. Challenge Write a program that prints the decimal numbers from 1 to 100 inclusive. But for multiples of three print “Fizz” ...
9
votes
3answers
498 views

Manoeuvre the grid!

Briefing You are a bot, in a 2D grid that extends infinitely in all four directions, north, south, east and west. When given a number, you must move the bot so that you get to the target number. ...
51
votes
93answers
9k views

The alphabet in programming languages

Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose name starts with that letter. Input: none Output: abcdefghijklmnopqrstuvwxyz ...
17
votes
10answers
1k views

Comment-free polyglot

Polyglots are programs that are valid in multiple programming languages simultaneously. Most such polyglots are written in such a way that certain constructs of one language are interpreted as ...
7
votes
1answer
299 views

Comment-free polyglot with different, nontrivial, behaviour per language

This challenge is inspired by this other challenge, which you may want to read first for some context. However, a competitive answer is likely to look very different, so after reading some posts on ...
15
votes
16answers
3k views

Shuffle a deck without local variables

The object of this puzzle is to take a deck of 52 cards and shuffle it so that each card is in a random position. Given: An array, deck, of 52 distinct integers representing the cards. When you ...
-5
votes
4answers
162 views

Your Search Returned No Results [closed]

Your task is simple. Write a program (or function) whose output returns no search results on google. Rules: It must take no input. It must not cause an error. It must terminate. It must produce the ...
21
votes
2answers
486 views

On this site we obey the laws of thermodynamics!

And in particular the second law: the entropy of an isolated system increases over time. For this challenge, An "isolated system" will be taken to be a program or function (abbreviated as "program" ...
8
votes
2answers
285 views

The logical quine

The challenge Simply write a program that outputs its own source code. Nothing more than a regular quine. The problem We don't have a computer so we have to run the program on a programmable logic ...
34
votes
20answers
4k views

Code close to the challenge: Sum of integers

This is a simple challenge: Given a sequence of integers, find the sum of all integers in it. But with a twist. Your score is the Levenshtein distance between your code and the following phrase (The ...
6
votes
0answers
125 views

Out Steganograph Me! [duplicate]

Out Steganograph Me As a follow up to this challange, I want to see competitive algorithms for encoding strings as images, and then decoding them. The Challenge Your goal is to write a function or ...