A contest for writing unreadable code!
There has been a little known contest since 1984 for writing C code which is
creative, totally unreadable, and (possibly)
funny. The idea is to write a program which should work perfectly, but should not give out any details of the algorithm to a person looking at the code. Believe me, as simple as it may sound, it requires genius of the highest order to write code which is thoroughly obfuscated. The following program which approximates the value of
pi should give you an idea of what
The Obfuscated C Code Contest is all about:
/*
* 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()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}
The source code for the above program is in the form of a circle and the value of pi is calculated by calculating the actual area and perimeter of the circle in the program!
The most common method( if you haven't noticed it already) is to use the #define statement to redefine the keywords used in C and then write programs with the redefined keywords. The list of programs
here has an amazing collection of programs which use methods far more complicated than the one I just said. In particular, check out this
flipper program which inverts any block of text across the diagonal. (simple eh?) But if you invert the entire program code, it results in a program which does the exact same thing as the original program!!!
I should probably just let you check out the programs yourselves but I can't resist mentioning another amazing program which solves
differential equations. Big deal eh? wait.. the program incorporates a reversing filter which reverses any text. So? just use the reversing filter on the source code and presto! you have another C program which implemetnts a shell sort! Is that all? You bet it isn't.. Use the shell sort on the original source code and it generates a third C program which generates the Fibonacci numbers!!!!! How much more astounding can you get!
...