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).
15
votes
22answers
1k 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 ...
-1
votes
16answers
276 views
Print all the numbers! (At least, as many as possible.) [on hold]
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 ...
-1
votes
0answers
49 views
Encoding decoding code challenge [on hold]
Imagine an array of numbers 0 - 99
eg
var arrayOfNumbers = [ 0, 1, 2, 3..... ,98, 99 ];
Loop through every (x)th number and remove ( splice ) it from the original array and push it into a second ...
4
votes
0answers
142 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 ...
16
votes
1answer
208 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 ...
-4
votes
0answers
188 views
Getting really close to a Stack Overflow [closed]
Goal
Write a program that gets as close to a stack overflow as possible and put out the number of remaining bytes on the targeted stack before it would crash. The program should terminate without ...
12
votes
4answers
522 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
220 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
346 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 ...
8
votes
6answers
440 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 ...
185
votes
5answers
12k 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:
...
22
votes
1answer
559 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
185 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
62 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 ...
25
votes
2answers
641 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 ...
175
votes
31answers
25k 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
239 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
317 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
300 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
195 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
324 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
210 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
426 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 ...
224
votes
14answers
28k 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
320 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
402 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 ...
121
votes
84answers
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
422 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.
...
17
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
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 ...
7
votes
19answers
472 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
581 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
160 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 ...
58
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
253 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
115 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
0answers
173 views
Encode a steganographic encoder into a package
Introduction
By steganography we mean hiding a message along an existing text or image so the result would be unsuspicious of the existence of the original message. This challenge is about hiding ...
-4
votes
1answer
222 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
201 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
614 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
677 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
430 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 ...
13
votes
2answers
652 views
Carrots. So. Many. Carrots
The Inspiration
The Task
You must create a program, that, in as many languages as possible, replaces every instance of ^ with a markdown formatted link (meaning that if I was to post it in an ...
11
votes
3answers
202 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
418 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 ...
3
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
458 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 ...
2
votes
2answers
208 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 ...