You are to write a program that does one of the following.

  1. Only displays "Hello World" does nothing else
  2. Quits and nothing else (no output, no errors.)
  3. Takes one line of input, parses it as an integer, displays the first that many primes (or gives a nice error if it is given input that can't be parsed as an integer, or is less than 0.)
  4. Given one line of input, it parses it has a stock symbol, and checks online for the current stock value and its change.

The catch, it should not be apparent which function it performs. Namely, for someone looking at your code, it should not be apparent which function it will do. Also, it may only perform and be able to perform one function (it can not pick and choose.) How good a program is is determined by how uncertain someone is that looks at it as to what its function is, and also how familiar that person is with that language.

BONUS: If you in a clever way make it so although for any one compiler/intrpreter and platform, the program will also perform the same function, different compilers/interpreters or platforms, it will perform a different function. This bonus may only be collected if done cleverly.

BONUS: If your program only contains code that is capable of one function (save nothing, as empty code is capable of that), and it is not possible to make a simple modification unrelated to the function to allow it to perform a different function. For example: if you did

obfuscatedBool = 1g8uhad'l8fygrcetdu8y4fd/,.oe87fy4d --Magic
if obfuscatedBool: print "Hello World"

Would not count as obfuscatedBool could be made True or False to make it print "Hello World" or do nothing respectively.

INFINITY BONUS: If you realize both bonuses simultaneously, you are magic.

NEGATIVE BONUS: Using libraries with specific abilities to do the functions.

Voters, take the bonuses in to consideration, because the program with the most votes wins!

Note: If you say what your program does, make sure to use spoiler syntax!

  • 2
    \$\begingroup\$ To be honest, I can't understand most of the question. I go further and will say that I only understand the 4 points. \$\endgroup\$ – Ismael Miguel Mar 12 '14 at 22:27
  • \$\begingroup\$ Make a program such that it does one of the 4 things, but no one knows what. \$\endgroup\$ – PyRulez Mar 12 '14 at 22:39
  • 25
    \$\begingroup\$ And what about the bonuses? Seriously, even the question is obfuscated. \$\endgroup\$ – Ismael Miguel Mar 12 '14 at 22:49
  • 4
    \$\begingroup\$ Since this is a popularity-contest, what for is the bonus? \$\endgroup\$ – Ismael Miguel Mar 13 '14 at 2:24
  • 1
    \$\begingroup\$ @MukulKumar - as in, mine actually made sense? \$\endgroup\$ – TheDoctor Mar 13 '14 at 12:53

32 Answers 32


JavaScript ES6

I'm late to the party, but I was still the life of it.

alert(eval(`[${[..."29234652749082823"].reduce((p,c)=>p+c+(c-~-[2<<2][""<<""]&&" "))
=>c+(p.constructor==[j=+[]][j].constructor?" ":p)).replace((y=y.shift(),` `),y.split 
`7`)}]`).map(e=>e.toString( i--),i=4+[1<<3<<1<<2>>1][j]).map(_=>[_[j^j],_.slice(1)].
reduce((o,O)=>o.toUpperCase()+O)).join` `);

this prints Hello World.

I might explain it later.



#include <stdio.h>
int main(void) {
    int numbers[] = {1, 2, 3, 4};
    printf("%d\n", numbers[42]);

This can do anything, and you won't know what will happen. In theory, undefined behavior in C is allowed to do anything, including the behaviors you mentioned. Obviously, it doesn't happen in most compilers, but perhaps somebody could fine one where this happens.

  • 1
    \$\begingroup\$ I think this only counts if you actually find compilers who show the behaviors in the question. \$\endgroup\$ – Paŭlo Ebermann Mar 14 '14 at 17:01
  • \$\begingroup\$ o.O Didn't you read the compilers 'thingy'? \$\endgroup\$ – Anonymous Pi Mar 16 '14 at 2:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.