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

39
votes
22answers
4k views

First code golf decathlon

Tasks All competitors try to solve the following list of 10 tasks: math Read a positive integer n from input and return the sum of the cubes of the first n non-negative integers. For input 1, ...
15
votes
2answers
3k views
+150

Prime Nerd Sniping Pattern

Longest day of the year - here's something to waste the extra time... Overview Note this is not a popularity contest and not a graphical output challenge - you are only required to output a string ...
14
votes
0answers
247 views

Stacking Pythagorean Triangles

Background A Pythagorean triangle is a right triangle where each side length is an integer (that is, the side lengths form a Pythagorean triple): Using the sides of this triangle, we can attach ...
32
votes
4answers
687 views

Build a one-word search generator

The word BANANA appears exactly once in this word search: B A N A A N B B A B A N A B A N A N A B N N A A N N B A A A N N N A A N N N B A A N N N B A N A N A A B A N A N B A N A N B B A The word ...
42
votes
6answers
4k 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 ...
16
votes
5answers
644 views

Boggle Board Compression

When working on Non-Palindromic Polyglot Boggle, I found it quite tedious to pack the codes as efficiently as possible onto the Boggle board, even with only two strings. But we're programmers, right? ...
6
votes
2answers
315 views

Coding hex board game

Introduction Hex is a strategy board game played on a hexagonal grid, theoretically of any size and several possible shapes, but traditionally as an 11×11 rhombus. Other popular dimensions are 13×13 ...
12
votes
1answer
712 views

Rearranging Words

You should write a program which receives two strings as input and outputs a sequence of movements which rearrange the first string into the second. You should use as few moves as you can. Both ...
10
votes
1answer
425 views

Non-Palindromic Polyglot Boggle

Introduction The number 101 is a palindrome, since it reads the same backwards and forwards. The number 105 is not. However, 105 in base eight is written as 151, which is palindromic. On the other ...
9
votes
2answers
230 views

Visit each drifting tracker

Your job is to replace the battery packs on many floating fish tracking devices in the shortest time. You must leave your base in the base helicopter and visit each tracker once, then return to the ...
0
votes
2answers
172 views

Make a valid error maker!

We've been twice challenged to make 'error quines' (see Make an error quine! and Make a slow error quine maker!), so why don't we try the opposite? Instructions Write a "program" that, when run, ...
21
votes
8answers
987 views

Make a slow error quine maker!

As part of his answer to Make an Error Quine!, @Falko proposed the following algorithm: How to create your own solution in 2 minutes? Open a new file in an IDE of your choice. Bang your ...
0
votes
0answers
94 views

The polyglot challenge! [duplicate]

A polyglot is a program which can be run by several different language's interpreters/compilers without failing. For example, the stackoverflow 404 page contains a polyglot which runs in Python, ...
13
votes
5answers
393 views

Print strings without sharing characters

Edit: Allowed to reuse whitespaces. Your task is to write n programs (or functions, or bodies of functions without using parameters or the function names) in the same language. The kth program ...
10
votes
1answer
297 views

Build a poisoned wine testing scheduler

Recently at Puzzling.SE, there was a problem that I wrote about determining which two bottles out of a larger number are poisoned when the poison only activates if both components are drunk. It ended ...
18
votes
7answers
526 views

Optimize the Scralphabet

Scralphabet A normal bag of Scrabble tiles contains the following letters (? is a blank tile, which can stand for any other letter): ...
7
votes
10answers
623 views

List Sophie Germain primes

The Question A Sophie Germain prime is a prime p such that 2p+1 is prime as well. For example, 11 is a Sophie Germain prime because 23 is prime as well. Write the shortest program to calculate Sophie ...
12
votes
1answer
196 views

Express a number - a modern “Des Chiffres et des Lettres”

Express a number Back in the 60s, the French invented the TV game show "Des Chiffres et des Lettres" (Digits & Letters). The goal of the Digits-part of the show was to come as close as you can to ...
4
votes
4answers
495 views

Many programs, few characters

Your task is to create many programs. The first outputs 1, the second outputs 2, etc. The higher you can go, the better! However, all of these programs must be made the same list of characters. You ...
14
votes
6answers
346 views

Princely Prefix by a Program in Pattern

You should write a program or function which outputs or returns as much of Chapter I of The Little Prince as it can. Your program or function has to be an M-by-N block of code containing only ...
42
votes
125answers
4k views

Evolution of OEIS

In this challenge, the goal is to recreate the On-Line Encyclopedia of Integer Sequences one sequence at a time. Similar to the Evolution of Hello World, each answer depends on a previous answer. ...
7
votes
3answers
606 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. ...
1
vote
2answers
363 views

Write an Antiquine [closed]

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 ...
15
votes
4answers
916 views

Make the largest infinity that you can!

The ordinal number system is a system with infinite numbers. A lot of infinite numbers. So many infinite numbers that it literally does not have an infinity to represent its own infiniteness. The ...
5
votes
3answers
3k views

Getting a Highscore in Kuku Kube [closed]

First of all, this is more a challenge, than a serious programming question, I would like to share. Some of you might know the game Kuku kube, where you have to identify a square in a grid, which has ...
1
vote
4answers
571 views

Memory is Expensive [closed]

You are a robot. You are stranded in a small cage with weird humans wearing weird suits looking at you. Your solar panel is malfunctioning, and your energy is running out. On the wall there is a ...
-2
votes
4answers
202 views

Write a program that takes as close to 1 second sharp to execute in your language [closed]

Write a program that takes as close to 1 second Wall-time sharp to execute in your language. Anything goes except to have the processor sleep / pause / wait, by either internal or relying on external ...
9
votes
4answers
494 views

Build a minimum-clue Sudoku unsolver

My attempt at stating this question, but with a more objective solving criterion. Your task is to build a program or function that takes a solved Sudoku grid S in the format of your choice and ...
18
votes
2answers
2k views

Brainf*** subprograms with unique outputs

You should write a 100-byte long brainfuck (BF) program. One character will removed from it in every possible way the resulting 100 new (99-byte long) programs. E.g. for the program ++.>. the 5 ...
14
votes
2answers
531 views

Build a top-front-side puzzle solver

A top-front-side puzzle is a puzzle where you are required to construct a 3-D shape of (usually cubic) blocks given three orthogonal views: a top view, a front view, and a side view. For example, ...
4
votes
0answers
201 views

Evening Commute Solver

I recently moved to an apartment overlooking the inner ring-road of town, and every day, a beautiful scene unfolds. The traffic lights are apparently so confusing (mostly because the Dutch are used to ...
-4
votes
5answers
257 views

Print the Longest Sentence

I've searched around, and cannot find a challenge too similar to this one--however, it would not surprise me if this is not the first of its kind. My apologies if I've overlooked something. The ...
16
votes
2answers
691 views

Help our robots reach the teleporter

UPDATE: Added a Python framework to get started. The space-station has been overtaken by crusher-bots. You must direct as many of our expensive and fragile tech-bots called "rabbits" to an exit ...
16
votes
3answers
694 views

Reconstruct a Permutation

Introduction Suppose that you are handed a random permutation of n objects. The permutation is sealed in a box, so you have no idea which of the n! possible ones it is. If you managed to apply the ...
8
votes
3answers
639 views

Self-shortening Prime Tester

Let's get right in to it. Your challenge is to make a program that does these things depending on its input: If the input is a number, output "Prime" if the number is a prime number and "Not prime" ...
6
votes
3answers
546 views

Finding Collatz-like rules with many loops

This code-challenge is related to the code-golf question Analyzing Collatz-like sequences but the goal is quite different here. If you are familiar with Collatz-like sequences you can skip to the ...
35
votes
5answers
3k views

Adding Numbers with Regex

I want to try a new type of regex golf challenge, which asks you to solve nontrivial computational tasks with nothing but regex substitution. To make this more possible and less of a chore, you will ...
4
votes
0answers
286 views

Tetris Tangrams

Introduction Tangrams are a classic puzzle involving arranging/fitting blocks into various shapes. From the Chinese 七巧板 - literally meaning "seven boards of skill". Let's take this idea and use the ...
15
votes
9answers
1k 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 ...
18
votes
4answers
1k views

How to count the syllables in a word

Input: You will be passed a string containing a single english word. All letters will be lowercase, and there will be no non-alphabetic characters in the string. Output: You will return an integer ...
18
votes
3answers
757 views

Finding all-but-one matches

This challenge is about writing code to solve the following problem. Given two strings A and B, your code should output the start and end indices of a substring of A with the following properties. ...
35
votes
6answers
3k views

Write a Quine in Plain English

Write a quine that consists of real English words separated by single spaces. A "word" is defined as a string containing only lowercase and uppercase letters (/[a-zA-Z]+/ in regex). To be "real" your ...
5
votes
5answers
726 views

Rosetta Stone Code Golf Challenge: Print Certain Numbers; all snippets must be same length

Rosetta Stone Code Challenges are challenges where you must complete the task in as many languages as possible. The Challenge You will be given two numbers, n and s, in a list as input. The n will ...
8
votes
2answers
642 views

Finding Programs in the Primes

Let's assign the numbers 0 through 94 to the 95 printable ASCII characters: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Space is 0, ! is 1, and ...
3
votes
3answers
411 views

Generate unique non-sequential string of length n without memory of previously generated strings

Scenario: Imagine a situation where you wish to share a unique alphanumeric code. Perhaps it is a one-time-use coupon code you hand write on business cards, or some other scenario where it is ...
7
votes
3answers
860 views

Recognize Twin Primes by Crashing

Background Story Bob was handed the following assignment for his programming class. Please note: this is not the actual challenge. Homework assignment 11: Twin primes Input: an integer n ...
32
votes
8answers
4k views

One hundred passwords

I have one hundred vaults, each one within another. Each vault has a password, consisting of a single number. 95 43 81 89 56 89 57 67 7 45 34 34 78 88 14 40 81 23 26 78 46 8 ...
6
votes
3answers
484 views

Your Language in a Box

Now with BONUS for run-time placement. Write a program to fill a text box with the identifiers used in your program while keeping your program small. With all the identifiers you have used (excluding ...
-1
votes
5answers
251 views

How many contiguous “strings” can you find in a set of strings?

Consider the set of 16-character strings containing only the 95 printable ASCII characters. There are 9516 ≈ 4.4×1031 such strings. Imagine these strings are put into a list and sorted ...
18
votes
3answers
1k views

Anagramming Stack Exchange question titles into programs

Stack Exchange currently has 134 question and answer sites. This includes all beta sites (such as PPCG) but not Area 51 proposals nor any meta sites, except for the "mother meta". To answer this ...