All Questions
13,821
questions
1223
votes
6
answers
298k
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 ...
619
votes
320
answers
236k
views
Produce the number 2014 without any numbers in your source code
Note to challenge writers as per meta consensus:
This question was well-received when it was posted, but challenges
like this, asking answerers to Do X without using
Y
are likely to be poorly received....
554
votes
1
answer
191k
views
Build a digital clock in Conway's Game of Life
Your task is to build a Game of Life simulation representing a digital clock, which satisfies the following properties:
The clock displays the hours and minutes in decimal (e.g. ...
550
votes
241
answers
134k
views
Showcase of Languages
Notes
This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not ...
515
votes
966
answers
187k
views
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
461
votes
50
answers
173k
views
Images with all colors
Similar to the images on allrgb.com, make images where each pixel is a unique color (no color is used twice and no color is missing).
Give a program that generates such an image, along with a ...
429
votes
23
answers
147k
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 ...
392
votes
49
answers
58k
views
Covfefify a string
In this challenge, you must take a string matching the regex ^[a-zA-Z]+$ or whatever is reasonable (you don't have to consider uppercase or lowercase letters if you ...
391
votes
156
answers
287k
views
Write a program that makes 2 + 2 = 5 [closed]
Write a program that seemingly adds the numbers 2 and 2 and outputs 5. This is an underhanded contest.
Your program cannot output any errors. Watch out for memory holes! Input is optional.
...
390
votes
36
answers
71k
views
American Gothic in the palette of Mona Lisa: Rearrange the pixels
You are given two true color images, the Source and the Palette. They do not necessarily have the same dimensions but it is guaranteed that their areas are the same, i.e. they have the same number of ...
382
votes
110
answers
89k
views
Most creative way to display 42
Douglas Adams was born on March 11, 1952, and died when he was just 49. In honor of this wonderful writer, I challenge you to display 42 in the most creative way possible.
You could print it in the ...
373
votes
1
answer
117k
views
Regex that only matches itself
There are some pretty cool challenges out there involving regex (Self-matching regex, Regex validating regex)
This may well be impossible, but is there a regex that will ONLY match itself?
NOTE, ...
358
votes
7
answers
50k
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:
<...
328
votes
40
answers
283k
views
High throughput Fizz Buzz
Fizz Buzz is a common challenge given during interviews. The challenge goes something like this:
Write a program that prints the numbers from 1 to n. If a number is
divisible by 3, write Fizz instead....
326
votes
176
answers
136k
views
Tips for golfing in Python
What general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is ...
326
votes
55
answers
110k
views
Tweetable Mathematical Art [closed]
Integer math can generate amazing patterns when laid out over a grid. Even the most basic functions can yield stunningly elaborate designs!
Your challenge
Write 3 Tweetable (meaning 140 characters ...
317
votes
24
answers
45k
views
Write Moby Dick, approximately
Here is a 1.2Mb ASCII text file containing the text of Herman Melville's Moby-Dick; or, The Whale. Your task is to write a program or function (or class, etc. -- see below) which will be given this ...
307
votes
7
answers
34k
views
Draw with your CPU
I have come across an article where students used network traffic to draw their university on the country's IPv6 graph. [image]
Your goal is simple to tell, but hard to implement. Draw the text MAIL (...
301
votes
450
answers
125k
views
Add a language to a polyglot
This is an answer-chaining challenge in which each answer builds on the previous answer. I recommend sorting the thread by "oldest" in order to be sure about the order in which the posts are ...
289
votes
73
answers
78k
views
We're no strangers to code golf, you know the rules, and so do I
Write the shortest program that prints the entire lyrics of "Never Gonna Give You Up" by Rick Astley.
Rules:
Must output the lyrics exactly as they appear in the above pastebin*. Here's the raw dump:...
278
votes
33
answers
93k
views
Make it look like I'm working
Often, I find myself running a script or query that will take a significant amount of time to run. I can leave that script open and enjoy some guilt-free procrastination.
Now, what if I could write a ...
277
votes
141
answers
503k
views
I need a program where the user inputs an array of doubles and the program outputs the array sorted
Note: This question was severely edited since I first posted it here. The rules were moved to here, read them before posting any answer to understand the purpose of this. This was the first question ...
269
votes
145
answers
37k
views
Without using numbers, get the highest salary you can. But don't exaggerate!
As I'm applying for some jobs whose job advert doesn't state the salary, I imagined a particularly evil interviewer that would give the candidate the possibility to decide their own salary ...by "...
258
votes
37
answers
49k
views
Paint Starry Night, objectively, in 1kB of code
Note: a 1000 point bounty is still available for this challenge, which I will create and award if anyone takes the top score without using built-in compression.
Below is a ...
250
votes
82
answers
82k
views
Code that will only execute once
Goal
The goal of this challenge is to write code that will execute once and only once. This means basically that it damages the program, script, or environment in some way. If rebooting the system ...
247
votes
56
answers
55k
views
Survival Game - Create Your Wolf
The Board
The Board is a two dimensional array of cells. Cells are populated by Animals. Every day, all Animals on the Board simultaneously make one move. If two or more Animals move to the same cell, ...
241
votes
447
answers
63k
views
Golf you a quine for great good!
Using your language of choice, golf a quine.
A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.
No cheating -- that means ...
239
votes
115
answers
43k
views
Print every character your program doesn't have
Your task is to build a program (using only printable ASCII characters and/or tabs and newlines) that prints out exactly the characters in the printable ASCII space (...
235
votes
184
answers
38k
views
Evolution of "Hello World!"
This contest is officially over, the winner is jimmy23013. Congratulations!
The challenge is to make a program that prints Hello World! to stdout. The catch is that ...
234
votes
363
answers
64k
views
Is this number a prime?
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in ...
233
votes
28
answers
24k
views
DISARM THE B.O.M.B.!
You have been hired for your tech knowledge as a Secret Agent's sidekick to ensure that the good guy can get his job done and the world can be saved.
This is your last mission before retiring with a ...
226
votes
63
answers
19k
views
No A, just CAPS LOCK
What happens when the CapsLock key on your keyboard doesn't have a notch in it?
"This hPPENS."
The goal of this program is to consistently emulate keyboard misses where each A press is replaced with ...
219
votes
89
answers
39k
views
Make your language unusable
Try to write some code in your language and make it not satisfying our criteria of being a programming language any more.
A language satisfies our criteria (simplified version for this challenge) of ...
198
votes
212
answers
45k
views
The Programming Language Quiz
Congratulations to Dennis who won both the cops' and the robbers' challenge! Calvin's Hobbies has already delivered on his promise and wrote this challenge for Dennis for winning the robbers' ...
197
votes
120
answers
27k
views
I'm not the language you're looking for!
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.
Challenge
You will have to write a program that ...
194
votes
62
answers
30k
views
Mathematics is fact. Programming is not
In mathematics an exclamation mark ! often means factorial and it comes after the argument.
In programming an exclamation mark ! ...
193
votes
412
answers
73k
views
1, 2, Fizz, 4, Buzz
Introduction
In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
193
votes
80
answers
26k
views
What? No error? [closed]
Your task is simple. Write a program that should obviously produce an error on first glance either when compiled or run, but either doesn't or produces some other unrelated error. This is a popularity ...
192
votes
175
answers
19k
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 ...
182
votes
29
answers
24k
views
Do you want to code a snowman?
Here is a simple ASCII art snowman:
_===_
(.,.)
( : )
( : )
Let's make him some friends. This will be the general pattern for our ASCII art snowpeople:
...
181
votes
50
answers
40k
views
Trolling the troll [closed]
A troll has captured you and is forcing you to write malware (defined as a program that damages the computer that runs it). The troll can read and understand code, but is not so good at spotting bugs.
...
174
votes
100
answers
40k
views
Programming Languages Through The Years
In this challenge, users will take turns completeing three fairly simple coding tasks in programming languages that are allowed to be progressively older.
The first answer must use a programming ...
173
votes
97
answers
66k
views
Tips for golfing in JavaScript
What general tips do you have for golfing in JavaScript? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to JavaScript (e.g. "remove ...
172
votes
483
answers
34k
views
Implement a Truth-Machine
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:
Gets a ...
172
votes
36
answers
24k
views
Write program in your favorite language in another language [closed]
The determined Real Programmer can write Fortran programs in any language.
from Real Programmers Don't Use Pascal
Your task is to write program in your programming language of choice, but you are ...
169
votes
8
answers
36k
views
Draw an Image as a Voronoi Map
Credits to Calvin's Hobbies for nudging my challenge idea in the right direction.
Consider a set of points in the plane, which we will call sites, and associate a colour with each site. Now you can ...
168
votes
166
answers
56k
views
Don't google "google"
We all know that if you google the word "google" it will break the internet.
Your task is to create a function that accepts one string and returns its length, in the fewest possible Unicode ...
168
votes
6
answers
18k
views
Hyperprogramming: N+N, N×N, N^N all in one
Write a program that takes in a number N from 1 to 9 inclusive. In its native form your program should output N+N. E.g. output 2 if N is ...
167
votes
70
answers
24k
views
How high can you count?
Challenge:
Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer ...
165
votes
128
answers
33k
views
Trick or Treat polyglot
Since Halloween is coming up I thought I might start a fun little code golf challenge!
The challenge is quite simple. You have to write a program that outputs either ...