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

-6
votes
0answers
84 views

Alpha beta beta pruning [on hold]

A MiniMax tree is an arborescence structure generated by an AI bi-player game to simulate the opponent turns giving notes/scores to each of, and so each turn taken by the player itself, in order that ...
2
votes
0answers
110 views

What's so great about 1729? [closed]

This is not a duplicate of this question. This is asking for the nth number that can be represented as the sum of two cubes in two different ways, while that is asking for the n-th number that can be ...
10
votes
0answers
190 views

Image Hide-and-Seek

In this challenge, you need to find a specific pixel within an photograph (taken with a real camera). You are passed an (R, G, B) tuple and an image, and you need to return a point (x,y) within the ...
1
vote
10answers
414 views

Hi, can you draw some odd art? Bye!

Create a program that outputs "Hi, Hello!" in k bytes. By altering n bytes, the code should output all odd numbers in the range 5 <= x <= 25. Changing another m bytes should result in a code ...
2
votes
1answer
195 views

Find the last three words of each paragraph if they are shorter than 20 characters in total

Based on my SO question, but more specifically: Find a RegEx such that, given a text where paragraphs end with an empty line (or $ at the very end), match the up to twenty last characters of a ...
4
votes
6answers
414 views

Traveling on a flat Earth

Coordinates in the flat-Earth world consist of latitude (x) and longitude (y), which are integers in the range 0...9999. Much like Gaussian integers, but they are always written using this notation: ...
7
votes
1answer
206 views

Reconstruct a missing RGB channel

Look at these photographs of natural scenes, with one of the RGB channels taken out of them: Source (with red): https://en.wikipedia.org/wiki/File:Altja_j%C3%B5gi_Lahemaal.jpg Source (with ...
18
votes
2answers
330 views

Virtual Keyboard Text Input

On modern game consoles and other devices without traditional keyboards, trying to input text is a nightmare. Having to type with a few buttons and a joystick on a virtual keyboard is annoying, and I ...
0
votes
0answers
68 views

A cycle of quine-like programs [duplicate]

This question asks you to write n programs, such that program 1 outputs program 2, program 2 outputs program 3, ... program n-1 outputs program n and program n outputs program 1. However, not all of ...
17
votes
2answers
783 views

Where will the cat go? (orbital mechanics)

A nearly massless cat is dropped in space (don't worry, with a space suit and everything) at the point (x, y, z) with velocity (vx, vy, vz). There is an fixed, infinitely dense planet (with volume of ...
10
votes
4answers
307 views

Find the shortest way to advance a counter to a certain number

I have a counter. It's a small device that looks like this: The display goes from 0000 to 9999. It has a little push-button at the top that increases the count by 1, and a little knob at the right ...
59
votes
19answers
3k views

Tweetable hash function challenge

In this code-challenge you will write a hash function in 140 bytes1 or less of source code. The hash function must take an ASCII string as input, and return a 24-bit unsigned integer ([0, 224-1]) as ...
17
votes
2answers
919 views

Fun with flags!

Write a full program with a source code of 256 bytes or less that looks at an image of a flag and determines what country that flag is from. A zip file containing the 196 different flags in the ...
-7
votes
2answers
226 views

Use all your language's keywords, ideally minimally [closed]

Your program must contain all your language's keywords. Ideally, you should have each one exactly once (see Scoring). Of course, this means your language must actually have keywords, so esoteric ...
15
votes
23answers
2k views

Good Old Suffix Vector

Inspired by an old manual... The challenge I define the ath suffix vector of b as the boolean list of length a with b trailing truthy values. Write a program or function that, given a and b by any ...
-2
votes
16answers
365 views

Print all the numbers! (At least, as many as possible.) [closed]

Your task is to print a number. Simple, right? It is simple, but not as simple as this. The first answer is to print the number 1, the second answer is to print the number 2, etc. Rules The first ...
6
votes
0answers
244 views

Generate ASCII Art

Given a black-and-white image in any reasonable lossless format (png, ppm, etc.; filename or raw bytes) as input, output ASCII art that is as close to the input image as possible. Rules Only ...
27
votes
3answers
812 views

Stuffing primes in a box

Your task is write a program or function that can fill a given rectangle with prime numbers. The width and height of the rectangle will be the input. The output must be a list of height strings ...
13
votes
6answers
683 views

Who said that? 2016 Presidential election

In this challenge, your task is to make write a program with less than 300 characters that takes a short paragraph or a few sentences that a candidate has said and output who said it. Input: Can be ...
7
votes
1answer
243 views

Model a probability table using 15-bit fixed probabilities

A histogram is an array of integers that counts the number of times a symbol occurs. For example, for the string "aaabbbabbdebabbbebebdbaaabbabaaaaeebeaabaaba" a histogram is a: 18, b: 18, c: 0, d: 2, ...
8
votes
5answers
385 views

Word or near-word?

Write a program or function that given a string (or your language's equivalent), determine if the string is a word, or not, and output a truthy or falsy value. (This is not a duplicate of Is this ...
10
votes
6answers
581 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 ...
188
votes
5answers
13k views

Upgoat or Downgoat?

Given an image of a goat, your program should best try to identify whether the goat is upside down, or not. Examples These are examples of what the input may be. Not actual inputs Input: Output: ...
24
votes
1answer
605 views

The PPCG Handicap System

As we all know, meta is overflowing with complaints about scoring code-golf between languages (yes, each word is a seperate link, and these may be just the tip of the iceberg). With so much jealousy ...
-3
votes
1answer
214 views

“I know that language - that's Java. No? It's Perl?” [duplicate]

Introduction A known fact is that Jon Skeet can code Perl and make it look like Java. In this challenge you will try to do something similar. Challenge Write a piece of code of any length that can ...
1
vote
0answers
68 views

Windows batch polyglot/hybrids challenge with any language possible [closed]

/* I hope such question is suitable for here*/ As the batch scripts are pretty limited, hybrid files that embed a code from another language into a batch file are used a lot lately. Though usually ...
26
votes
2answers
699 views

Compress an image to a 4 KiB preview

In this challenge you will be creating an image preview compression algorithm. It's goal is to reduce an arbitrary image file to a 4 KiB preview image, that can be used to quickly identify images with ...
179
votes
32answers
26k views

Paint Starry Night, objectively, in 1kB of code

Below is a 386x320 png representation of van Gogh's Starry Night. Your goal is to reproduce this image as closely as possible, in no more than 1024 bytes of code. For the purposes of this ...
15
votes
4answers
1k views

What's the Language?

Recently, the PPCG design leaderboard has been having some trouble parsing answer html headers. In this challenge you'll be taking your own shot at parsing answer headers. Example Test Cases ...
15
votes
1answer
246 views

Know a sequence by its subsequences

Introduction Suppose you and your friend are playing a game. Your friend thinks of some particular sequence of n bits, and your task is to deduce the sequence by asking them questions. However, the ...
7
votes
6answers
325 views

The branch predictor challenge

Every day, every minute, ... every microsecond, many decisions are made by your computer. In high-level languages, these typically take the form of statements like if, while and for, but at the most ...
12
votes
2answers
310 views

A register calculator challenge

A simple register calculator This challenge involve a simple register calculator that works in the following way: It has some registers named A,B,C,...,Z, each of them can contain an integer, they ...
9
votes
1answer
212 views

Sort scrambled two-dimensional array filled with numbers by swapping adjacent numbers [closed]

A two-dimensional array of size n×n is filled with n*n numbers, starting from number 1. Those numbers are to be sorted per row in ascending order; the first number of a row must be greater than the ...
7
votes
6answers
348 views

Inverse symbolic calculator

This challenge is based on the idea of Plouffle's Inverter. Write a program in any language that does the following: Takes as input a non-negative rational number X written in decimal, for example ...
-6
votes
2answers
217 views

Stop Internet Warming! [closed]

Task Write a program that will output another distinct program, and so on, while using as few distinct characters (and as few bytes) as possible. For example, program 1 should output program 2, and ...
29
votes
4answers
450 views

Plurality Voting with Cellular Automata

There's a really important problem in cellular automata called the Majority problem: The majority problem, or density classification task is the problem of finding one-dimensional cellular ...
226
votes
14answers
29k 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 ...
15
votes
2answers
341 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
425 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 ...
128
votes
93answers
11k 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 ...
7
votes
4answers
465 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. ...
18
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 ...
23
votes
9answers
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 ...
7
votes
19answers
504 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 ...
13
votes
4answers
587 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
167 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 ...
28
votes
11answers
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 ...
65
votes
28answers
6k 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
261 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
137 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 ...