367
votes
135answers
142k views

Produce the number 2014 without any numbers in your source code

So, now that it's 2014, it's time for a code question involving the number 2014. Your task is to make a program that prints the number 2014, without using any of the characters 0123456789 in your ...
321
votes
97answers
54k 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. Now this can be printed in ...
262
votes
34answers
45k 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 ...
259
votes
96answers
137k views

Write a program that makes 2 + 2 = 5

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. ...
213
votes
39answers
50k 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 ...
198
votes
31answers
23k 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 ...
181
votes
7answers
16k 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 ...
169
votes
73answers
15k views

What? No error?

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 ...
165
votes
53answers
19k 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 ...
157
votes
43answers
25k views

Trolling the troll

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. ...
154
votes
11answers
12k 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 ...
149
votes
57answers
7k views

Fibonacci Sequence Generator

Can you create a clever or unexpected Fibonacci generator? Your code must print or return either the nth Fibonacci number or the first n Fibonacci numbers.
134
votes
53answers
51k 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 ...
126
votes
112answers
34k views

Weirdest way to produce a stack overflow

As a programmer you certainly know the error of a stack overflow due to an obvious recursion. But there are certainly many weird and unusual ways to get your favourite language to spit that error out. ...
123
votes
34answers
15k views

Write program in your favorite language in another language

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 ...
118
votes
51answers
21k 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 (0x20 to 0x7e) that don't appear in ...
116
votes
49answers
54k 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 ...
109
votes
47answers
9k views
+100

Caveman Duels (or: Me poke you with sharp stick)

Caveman mad. Other caveman take stick but stick was for me. Caveman fight! Description Caveman need sharp stick to stab other caveman. Other caveman also try to stab with sharp stick. Caveman ...
104
votes
19answers
49k views

How slow is python really? (Or how fast is your language?)

I have this code which I have written in python/numpy from __future__ import division import numpy as np import itertools n=6 iters = 1000 firstzero = 0 bothzero = 0 """ The next line iterates over ...
98
votes
7answers
19k views

So obviously, P = NP

SAT is the problem of determining whether a boolean expression can be made true. For example, (A) can be made true by setting A=TRUE, but (A && !A) can never be true. This problem is known to ...
97
votes
51answers
24k views

Draw the Olympic Games logo

Challenge Draw the Olympic Games logo... ...as character (e.g. ASCII) art! Sample Output * * * * * * * * * * * * * * ...
96
votes
91answers
15k views

Good Versus Evil

Results - July 19, 2014 The current King of the Hill is Mercenary by user Fabigler! Keep submitting entries and knock him off of his throne! Click here to view the Scoreboard. Programs submitted on ...
91
votes
63answers
15k views

Random script that isn't actually random

As a little joke in the office someone wanted a script that randomly picks a name, and said person will make a round of drinks. Let's call the people John, Jeff, Emma, Steve and Julie. I thought it ...
91
votes
10answers
14k views

Emulate an Intel 8086 CPU

Note: A couple of answers have arrived. Consider upvoting newer answers too. C from user1662116 C++ from Darius Goad Postscript from luser droog C++ from JoeFish Javascript from entirelysubjective ...
85
votes
107answers
18k views

4, 8, 15, 16, 23, 42

4, 8, 15, 16, 23, 42 Write a program that outputs this sequence of numbers infinitely. However, The Numbers must not appear in your source code anywhere. The following is not a valid Java program to ...
85
votes
45answers
7k views

Survival Game - AlienWar

AlienWar This game takes place in a very crowded planet where aliens are the superior race. Your task is to create your own alien and beat all other. The Board It is a 2 dimensional board. The ...
85
votes
37answers
11k views

Write a program that always outputs “2012” - even if it's modified!

This idea is not mine, though I don't know where it originated. I once met it in a programming contest very long ago (1998, if I remember correctly). The task is to write a program in your favorite ...
80
votes
65answers
13k views

Why isn't it ending?

Your task: To write a program that should obviously terminate, but it never (to the extent of a computer crash) does. Make it look like it should perform a simple task: adding numbers, printing ...
79
votes
143answers
10k views

Execute prints backwards

Your task is to reverse the order in which some prints get executed. Specs: Your code will be in this form: //some lines of code /*code*/ print "Line1" /*code*/ /*code*/ print "Line2" /*code*/ ...
74
votes
25answers
8k views

Make a scalable Christmas Tree

Your challenge: Make a Christmas tree. The size must be choosable by some input method, but doesn't have to be directly related to any part of the tree; however, larger inputs should produce a larger ...
73
votes
55answers
9k views

-ENDED- Do something that looks like something else

Write a snippet, a function, a programm, ... that is obfuscated in a way that it looks clear at the first sight that it does something else. For example: write a bit of code that adds two number, but ...
73
votes
14answers
8k views

Has my milk expired?

Aww, man, this expiry date doesn't write the months with letters! I can't tell if it's expiring on March 10th or October 3rd... Wait, no, never mind, the year says 2012. (alley-oops half-used brick of ...
72
votes
91answers
13k views

When does (x == x+2)?

The challenge: Define x in such a way that the expression (x == x+2) would evaluate to true. I tagged the question with C, but answers in other languages are welcome, as long as they're creative or ...
70
votes
68answers
13k views

Hello world! with limited character repetition

In a language of your choice, write a program that exactly outputs the characters Hello world! followed by a newline. The code: should not use any character more than twice (alphanumeric, symbol, ...
69
votes
17answers
13k views

Undefined Behavior Killed My Cat

Undefined Behavior Killed My Cat It's well known that undefined behavior can kill your cat [citation needed]. But can it? Your Task Write a program that invokes undefined behavior. Describe a ...
66
votes
72answers
15k views

Obfuscated Hello World

Create the shortest possible obfuscated program that displays the text "Hello World". In order to be considered an obfuscated program, it must meet at least two of the following requirements: ...
64
votes
43answers
9k views

Tips for golfing in Python

What general tips do you have for golfing in Python? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Python (e.g. "remove comments" is ...
64
votes
11answers
16k views

I am passive aggressive and want to insult my boss without him finding out

It's been a rough few months at work and I feel like I just want to scream right to my boss' face. I am, however, not one to directly confront people I have a problem with. I also don't want to lose ...
63
votes
109answers
17k views

Loop without 'looping'

A question similar to this has been asked a couple of years ago, but this one is even trickier. The challenge is simple. Write a program (in your language of choice) that repeatedly executes code ...
63
votes
77answers
5k views

Code Golf Christmas Edition: How to print out a Christmas tree of height N

Given a number N, how can I print out a Christmas tree of height N using the least number of code characters? N is assumed constrained to a min val of 3, and a max val of 30 (bounds and error ...
63
votes
61answers
12k views

Largest Number Printable

Before opening this I've done a little search and I've found there is a similar question, but it has been closed because it was ambiguous. I hope this won't. So, your goal is to write a program that ...
63
votes
56answers
8k views

The Rock, Paper, Scissors, Lizard, Spock Tournament of Epicness

Most Recent Leaderboard @ 2014-07-30 01:30 +-------+---------------------+-------------------------+----------+-------+-----+------+------+----------------+ | Pos # | Author | Name ...
61
votes
73answers
9k views

Call a method without calling it

Inspired by a now deleted StackOverflow question. Can you come up with a way to get a particular method executed, without explicitly calling it? The more indirect it is, the better. Here's what I ...
61
votes
11answers
6k views

Make a circle illusion animation

Your job is to animate this circle illusion. It looks like the points rotating inside of the circle, but they are actually just moving in straight lines. Criterias The result has to be animated. ...
61
votes
18answers
3k views

BattleBots: The Tournament

The results are in, the contest is over. The winner is arshajii's EvilBot with 14 wins ahead of Neo-Bot with 13 wins and CentreBot and LastStand with 11 wins each. Scores from the final run ...
60
votes
23answers
7k views

Contest: fastest way to sort a big array of Gaussian-distributed data

Following the interest in this question, I thought it would be interesting to make answers a bit more objective and quantitative by proposing a contest. The idea is simple: I have generated a binary ...
58
votes
10answers
9k views

The 9 Billion Names of God

The 9 Billion Names of God is a short story by Arthur C. Clarke. It's about a group of Tibetan monks whose order is devoted to writing down all the possible names of God, written in their own ...
58
votes
15answers
11k views

9 Hole Challenge

The 9 Hole Challenge 9 code golfing challenges of varying difficulty. Penalties for using the same language more than once. The question will be updated with pars, hole champions and trophy ...
56
votes
19answers
8k views

Rearrange pixels in image so it can't be recognized and then get it back

Create a program which can rearrange pixels in image so it can't be recognized. However your program should able to convert it back to original image. You can write two functions - for encoding and ...
56
votes
12answers
5k views

Insert typos into text

I wrote some text, but it looks too professional. I want to make it look like I was really tired when I wrote it. I need you to insert some typos. Your challenge is to take an arbitrary single line ...

15 30 50 per page