Ob- = O = obi-wan error

Obfuscated C Contest n.

(in full, the `International Obfuscated C Code Contest', or IOCCC) An annual contest run since 1984 over Usenet by Landon Curt Noll and friends. The overall winner is whoever produces the most unreadable, creative, and bizarre (but working) C program; various other prizes are awarded at the judges' whim. C's terse syntax and macro-preprocessor facilities give contestants a lot of maneuvering room. The winning programs often manage to be simultaneously (a) funny, (b) breathtaking works of art, and (c) horrible examples of how not to code in C.

This relatively short and sweet entry might help convey the flavor of obfuscated C:

/*
 * HELLO WORLD program
 * by Jack Applin and Robert Heckendorn, 1985
 * (Note: depends on being able to modify elements of argv[],
 * which is not guaranteed by ANSI and often not possible.)
 */
main(v,c)char**c;{for(v[c++]="Hello, world!\n)";
(!!c)[*c]&&(v--||--c&&execlp(*c,*c,c!!c+!!c,!c));
**c=!c)write(!!*c,*c,!!**c);}

Here's another good one:

/*
 * Program to compute an approximation of pi
 * by Brian Westley, 1988
 * (requires pcc macro concatenation; try gcc -traditional-cpp)
 */

#define _ -F<00||--F-OO--;
int F=00,OO=00;
main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
            _-_-_-_
       _-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
        _-_-_-_-_-_-_-_
            _-_-_-_
}

Note that this program works by computing its own area. For more digits, write a bigger program. See also hello world.

The IOCCC has an official home page at http://www.ioccc.org.

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.

The International Obfuscated C Code Contest, often called the IOCCC, is an (almost) annual contest to cram as much C code into an arbitrary size limit yet still having an interesting program. Some people have fun decyphering the code, while others think it's a pointless waste of time. Yet others wish the other two would stop arguing about it.

The IOCCC has a bad reputation of hosting "Bad C code" - it even says so on the website. In fact, it is quite the opposite; it is easy to write a quick C program, change all the variable names to one-character long names, remove all the whitespace, and call it obfuscated - and that is why 100% of the IOCCC winners do more than this.

As an example, try 2000/dhyang.c (code/hint). This is not just a quine; it prints a program, that prints another program, that prints another program, and so on... in a mutually-reproducing cycle. Not to mention that the code is in the layout of Saitou Hajime...

Another example: 1994/schnitzi.c (code/hint). When you compile and run, it converts a file from this:

abc
def
ghi
To this:
adg
beh
cfi
That is, it flips a file along the top-left-bottom-right diagonal. If you try to run the program on its own code, you get a new program that compiles to do the same thing, along with revealing a secret message and having completely different bits of code than the original.

The Jargon File entry above me shows possibly the most famous entry, 1988/westley.c (code/hint) - it calculates π from working out its own area. Even though it's not as obfuscated as the other entries, it's pretty darn clever.

The rules are meant to be as loose as possible - if a hole is found, the judges will plug the hole "with as small a plug as possible, if not smaller". Although breaking the size limit or abusing the submission process just annoys the judges, active rule-bending is encouraged, and most years there is a "Best/worst abuse of the rules" award for the entry that does so.

Other entries include a completely blank entry ("the world's smallest quine!"), a complete x86 operating system, a PET emulator, and three different programming languages in the same file - all in a few kilobytes of source.

Despite this, there are still people that exclaim "But these entries are crap! You can't read the source code - it's illegible! This person obviously doesn't know anything about C." These people could not be further from the truth. Although it's easy to produce illegible code, it takes mastery of a language to produce obfuscated code of the level shown here.


The 2005 winners have been announced on November 6th: http://www.ioccc.org/whowon2005.html

Log in or register to write something here or to contact authors.