348
votes
128answers
134k 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 ...
284
votes
90answers
48k 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 ...
274
votes
141answers
95k 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 ...
176
votes
38answers
41k 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 ...
150
votes
71answers
12k 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 ...
150
votes
49answers
15k 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 ...
143
votes
46answers
6k views

Code Chess: Fibonacci Sequence [closed]

Building upon the proven success of Code Golf, I would like to introduce Code Chess. Unlike Code Golf, which strives for concision, Code Chess will strive for cleverness. Can you create a clever or ...
138
votes
40answers
21k 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. ...
122
votes
54answers
49k 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 ...
120
votes
109answers
32k 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. ...
115
votes
34answers
14k 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 ...
98
votes
50answers
17k 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 ...
94
votes
51answers
23k views

Draw the Olympic Games logo

Challenge Draw the Olympic Games logo... ...as character (e.g. ASCII) art! Sample Output * * * * * * * * * * * * * * ...
92
votes
7answers
17k 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 ...
81
votes
37answers
10k 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 ...
79
votes
106answers
16k 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 ...
77
votes
9answers
12k 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 ...
73
votes
138answers
9k 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*/ ...
71
votes
25answers
7k 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 ...
69
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 ...
68
votes
69answers
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, ...
66
votes
17answers
12k 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 ...
65
votes
47answers
22k views

How to write a C program for multiplication without using the * and + operators?

Is it possible to write a C program that multiplies two numbers without using the multiplication and addition operators? I found this on Stack Overflow. Please help this poor programmer with ...
63
votes
89answers
11k 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 ...
63
votes
60answers
11k 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 ...
63
votes
77answers
4k 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 ...
62
votes
60answers
11k 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 ...
58
votes
73answers
13k 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: ...
58
votes
18answers
2k 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 ...
58
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 ...
53
votes
42answers
7k 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 ...
53
votes
25answers
11k views

Shortest unmatchable regular expression

Your mission is to write the shortest valid regular expression that no string can match, empty string included. Submissions must have this form ("literal notation"): /pattern/optional-flags ...
53
votes
6answers
5k views

Is it dark outside? Draw a sun map!

Our closest star, the sun, is quite fidgety. The times it rises and sets depend on where you are, and whether it is winter or not. We would like to be able to deduce if the sun is shining outside ...
52
votes
38answers
10k views

Could you please tell me the time?

You know that your language's clock/time API's are broken and they are not reliable at all. So you are not allowed to use any built-in API to access system time/date. But you also know that your ...
52
votes
64answers
8k 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 ...
52
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 ...
51
votes
14answers
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 ...
50
votes
30answers
7k views

Generate an understandable sentence

Problem: Generate a sentence that can be read and understood. It must contain a subject, verb, and object, and tenses and plurals must match. The program must also be able to generate several ...
48
votes
95answers
10k views

99 Bottles Of Beer

Recreate '99 bottles of beers on the wall'. The desired output is this: 99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 ...
48
votes
69answers
7k views

“Creative” ways to determine if an array is sorted

Given an integer array, write a program that determines if it is sorted in ascending order. Remember that this is a code trolling question. I am looking for most interesting ways that people come up ...
48
votes
27answers
6k views

Mandelbrot image in every language

I always used a Mandelbrot image as the 'graphical' version of Hello World in any graphical application I got my hands on. Now it's your guys' turn. Language must be capable of graphical output or ...
47
votes
30answers
7k views

Print your code backwards - reverse quine

Write a program that prints its own source code out backwards. Scoring: +50 if you use pull data from the Internet. +25 if you read your own source code. +1 point per character Lowest score wins. ...
47
votes
37answers
7k views

My daughter's alphabet

The other day we were writing sentences with my daughter with a fridge magnet letter. While we were able to make some(I love cat), we didn't have enough letters to make the others (I love you too) due ...
46
votes
43answers
7k views

π Day puzzle for 3/14

Happy π Day. The goal of this question is to calculate the area for a circle of radius 3, where A = πr². The catch is that you have to use the constant π that is defined in a different language ...
46
votes
30answers
7k views

Factorial in haiku!

Problem: Create a program that calculates the factorial of a number (using no built-in factorial functions). Easy? The catch is that you must write your entire program (including testing it) in haiku ...
46
votes
34answers
2k views

Golfing A Weasel Program

Richard Dawkins in his book The Blind Watchmaker, describes a Weasel program. The algorithm can be described as follows: Start with a random string of 28 characters. Valid characters are all ...
45
votes
70answers
8k views

Print the alphabet without using each vowel

Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'. Your task is to write a set of (up to 5) programs in any language (which has a ...
45
votes
31answers
13k views

All Your Base Are Belong To Us (Restricted)

Input must not be required, and output must read "All your base are belong to us". Restrictions No external resources. Plus a minimum of two of the following: You cannot use "a", "b", "t", "u", or ...
45
votes
23answers
6k views

Implement Sleep Sort

Sleep Sort is an integer sorting algorithm I found on the Internet. It opens an output stream, and for each input numbers in parallel, delay for the number seconds and output that number. Because of ...
44
votes
74answers
10k views

How do I write an adding function?

The problem: I am the lead developer for a big company, we are making Skynet. I have been assigned to Write a function that inputs and returns their sum RULES: No answers like ...

15 30 50 per page