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

12
votes
2answers
215 views

Befunge Brain Teasers

Introduction For the ones wondering what Befunge exactly is, it is a two-dimensional stack based language made in 1993 by Chris Pressy. I made 7 brain teasers that need to be solved in Befunge-93. ...
8
votes
3answers
309 views

Egg dropping contest

Your challenge: You are on the 0th floor of a infinitely tall building. At any floor, you can walk to the window and drop an egg. Your goal is to figure out the highest floor that the egg can ...
110
votes
77answers
9k 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 ...
6
votes
4answers
345 views

Staircase Program

The challenge is simple: given two parameters, x and y, output y staircases with x steps. For example: f(3,1) - 1 staircase with 3 steps. _ _| _| f(5,2) - 2 staircases with 5 steps. ...
16
votes
10answers
2k views

Print the QWERTY keyboard using keys that are as close together as possible

Normally, challenges are scored in bytes, or sometimes Levenshtein distance, but for this one we're using keyboard distance -- the number of keys between the keys used to type the program (use the ...
21
votes
10answers
2k views

Chaining Programs

Challenge In this challenge, you will be writing the first program, p1, of an infinite sequence of programs, in which running pn outputs/generates program pn+1. When concatenating the first n >= 2 ...
4
votes
18answers
389 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 ...
12
votes
4answers
542 views

An executable script file that runs on POSIX and Windows

Challenge: write a single script file foo.cmd which can be invoked from the vanilla Windows cmd.exe prompt (not PowerShell, not in administrator mode), to execute arbitrary Windows-specific code... ...
4
votes
0answers
147 views

Finding the smallest grid of squares [closed]

Inspiration from Puzzling.SE. Suppose we have an m × n grid such that each element is a base 10 digit. We can read the numbers from such a grid so that we fix a starting element, go to one of the ...
26
votes
10answers
1k views

Find the largest gap between good primes

Following the fine tradition of questions such as Find the largest prime whose length, sum and product is prime , this is a variant on a largest prime challenge. Input Your code should not take any ...
51
votes
23answers
5k 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. ...
7
votes
3answers
196 views

Guess the hidden communities

Background This challenge is about the stochastic block model. Basically, you are given an undirected graph, where the nodes represent people, and the edges represent social connections between them. ...
-2
votes
1answer
86 views

Creating a colour chart in PHP will all colours [duplicate]

Now, before we begin, this has already been done here. But!, there are no PHP answers. With that in mind, my CodeGolf is thus: create a program to show all the colours in the html CSS spectrum using ...
-4
votes
1answer
203 views

Check my program! [closed]

Challenge Make an error-checker in the least amount of possible bytes! If you received an HTML program as a string through standard input, your program will be able to find all the errors and return ...
2
votes
1answer
193 views

Quine Pride Parade!

These days, I watched on TV a Gay Pride parade; at the time, I was thinking about quines and how they're a bit queer, outputting themselves (out of the closet?) and, well, why not combine both things ...
17
votes
7answers
539 views

Finding sum-free partitions

Executive summary Given input k, find a partition of integers 1 to n into k sum-free subsets for the largest n you can within 10 minutes. Background: Schur numbers A set A is sum-free if its ...
13
votes
3answers
663 views

An optimization challenge with strange coins

You have n coins which each weigh either -1 or 1. Each is labelled from 0 to n-1 so you can tell the coins apart. You have one (magic) weighing device as well. At the first turn you can put as many ...
15
votes
6answers
401 views

Who's that probability distribution?

Introduction In this challenge, you are given a list of nonnegative floating point numbers drawn independently from some probability distribution. Your task is to infer that distribution from the ...
11
votes
3answers
201 views

Fit the factors in the field

Given a positive integer below 1000, display all possible rectangles with that area. Task Let's say the input is 20. We can make a rectangle 20×1, 10×2, or 5×4, so this is a valid output: ...
9
votes
1answer
409 views

Variant of racetrack with exact finishing point and zero terminal velocity

Introduction The challenge is a very interesting variant of the game racetrack and those two challenges: To Vectory! – The Vector Racing Grand Prix Program a Racing Car Source of this ...
2
votes
9answers
1k views

How's your string theory?

Back to the basics! You're in you comp sci class again, except wiser and golfier. You have the tools, you have the power… but do you have the skill? Probably. Crash Course for the non-Computer ...
6
votes
5answers
417 views

Remove Whitespace from a Java Program [closed]

In this challenge, you will be given the source code of a Java program. Your task is to write a function or full program that will remove the whitespace from this program. The whitespace-removed ...
0
votes
0answers
132 views

Optimizing View Counts

Objective You run a video site like YouTube or Vimeo. Each video has a unique ID which is a 32-byte string containing any of the following characters: a-zA-Z0-9. You are tasked to perform view ...
2
votes
2answers
202 views

Greater Average Submatrix

Objective Write a program in any language that reads a matrix from stdin in which all columns are space delimited and all rows are newline delimited. The program must output a sub matrix so as that ...
13
votes
1answer
316 views

Make a (software) modem!

Objective Design a modulator/demodulator pair to accurately transmit data as quickly as possible over simulated plain old telephone service (POTS). Steps Generate some random (/dev/random or the ...
36
votes
26answers
3k views

Difference should make no difference

Your company lately hired a new bunch of extremely dedicated sysadmins. They feel that just watching computer screens is quite limiting (I mean, 60Hz refresh rate is just NOT enough), so they hooked ...
90
votes
35answers
5k views

Source code ecological footprint

You've just been hired by a German car manufacturing company. Your first task, as an engineer, is to write a program that computes the ecological footprint of ASCII strings. The ecological footprint ...
8
votes
4answers
429 views

Write two programs that compresses and decompresses data

Challenge: Create a program that compresses a semi-random string, and another program that decompresses it. The question is indeed quite similar to this one from 2012, but the answers will most ...
27
votes
7answers
2k views

Beatles Songs and Hexagons

Write two triangle (i.e. pyramid) shaped programs. The first one should be an upwards pointing text triangle with a minimum base width of three characters. So it would have a structure like X XXX ...
34
votes
5answers
702 views

Overcoming cluster size

Fed up with the reliability of flash storage, you decided to store all your programs on one of those good old 1,440 KiB floppies. However, after copying not even 3,000 programs, the disk was full. ...
35
votes
22answers
3k views

Remapping ASCII

Challenge Write a program that reorders the ASCII characters! It should output a single string containing all of the printable ASCII characters exactly once. The first character of this string is ...
16
votes
4answers
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. ...
8
votes
10answers
1k views

A Program that Prints Programs

Challenge Your goal is to write a program that prints another program. That printed program should print another program, and the new program should print another program, until the end. Rules ...
32
votes
106answers
3k views

Let's make a word-search!

In this challenge, we will together create a word-search containing many programs in different languages. I have started us off with a grid of 60-by-25 blanks (·), some of which are replaced by the ...
13
votes
0answers
309 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 ...
11
votes
1answer
387 views

An optimization version of the Hadamard problem

First, some definitions. A Hadamard matrix is a square matrix whose entries are either +1 or −1 and whose rows are mutually orthogonal. The Hadamard conjecture proposes that a Hadamard matrix of ...
19
votes
4answers
1k views

Golfing strings in Fourier

Challenge Given a string as input, golf down the Fourier program which outputs that string. In Fourier there is no easy way to output a string: you have to go through each character code and output ...
2
votes
0answers
123 views

Num of pyramids possible with given number of bricks [closed]

I encountered this question in an interview and could not figure it out. I believe it has a dynamic programming solution but it eludes me. Given a number of bricks, output the total number of 2d ...
11
votes
1answer
475 views

Lossless English language text compression challenge [closed]

Challenge: Your challenge (should you choose to accept it) is to compress and decompress the 5MB "Complete Works of William Shakespeare" as found here: ...
-2
votes
1answer
198 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. ...
1
vote
3answers
462 views

Brainf*** code golf challenge - write a Brainf*** program that searches for the first non-zero cell

The challenge is to write a brainf*** program that searches sequentially through memory for the first NON-zero cell. The program should start somewhere in fairly low memory (there will probably be ...
5
votes
0answers
424 views

Take It or Leave It III: A Game Show for Computers

This is the third in a series of puzzles that I will be posting every Monday at Midnight PST, and the final variant of "Take It or Leave It". The first puzzle is located Here The second puzzle is ...
13
votes
4answers
401 views

Find the largest independent set in a high-dimensional lattice-like graph

For a given positive integer n, consider all binary strings of length 2n-1. For a given string S, let L be an array of length n which contains the count of the number of 1s in each substring of ...
4
votes
1answer
390 views

Reflections in Water [closed]

Take a string as input. This string can be as long as you'd like, however, it may only include letters and spaces––no numbers, punctuation, etc. When a word is passed into your function, an image will ...
20
votes
7answers
3k views

Take It or Leave It II: A Game Show for Computers

This is the second in a series of puzzles that I will be posting every Monday at Midnight PST. The first puzzle is located Here. Context: A reclusive billionaire has created a game show to ...
28
votes
5answers
2k views

Take It or Leave It: A Game Show for Computers

Context: A reclusive billionaire has created a game show to attract the world's best and brightest programmers. On Mondays at the stroke of midnight, he chooses one person from a pool of ...
6
votes
1answer
301 views

Cross platform… You wish

Write a program that will produce differing behaviors on as many different platforms as you can. Each differing platform awards one point (including an initial platform, meaning you can't score less ...
-6
votes
6answers
163 views

Deep thought: Levenshtein distance [duplicate]

So, blatantly plagiarizing from inspired by this challenge and its sequel, I thought I'd add another. The text to match: What do you get when you multiply six by nine The result your ...
3
votes
2answers
674 views

A Kingdom Hearts VGM challenge

I'm a huge video game music fan. One of my favorite OSTs is that from Kingdom Hearts, by Yoko Shimomura. The challenge Create a program or function that takes two arguments in any format: an ...
1
vote
0answers
94 views

Minimizing Covering Arrays

This is the followup question to this previous CodeGolf question about Covering Arrays (the details of what Covering Arrays are and how they are formatted at the NIST website are there). In this ...