When a C programmer looks at the code from ICOOO, they will inadvertently open a door, realizing that C language can be played with in such creative ways.What is ICOOO? ICOOO stands for the International C Obfuscated Code Contest, a ‘performance art’ for C programmers. The goal of participants is not to write clear, maintainable code, but to create the most creative and confusing C programs possible. There is no such thing as the most chaotic, only more chaotic!Without further ado, let’s take a look at a winning piece from 1988:
Can you guess what its output is? This piece of code looks like a circle, but its true identity is—
That’s right, it calculates an approximation of π! It looks like a circle, but it is actually calculating π.
Decoding Journey: From Art to Mathematical Transformation
Step 1: Understanding the Core Macro Definition
<span>#define _ F-->00||-F-OO--;</span> is the heart of this program, and we need to dissect this “syntax trap”:
-
<span>00</span>is an octal number, equal to decimal 0 -
<span>F-->00</span>is equivalent to<span>(F--) > 0</span>—first compare if F is greater than 0, then decrement F -
<span>||</span>operator has short-circuit characteristics: if the left value is true, the right value calculation is skipped -
<span>-F-OO--</span>is equivalent to<span>(-F) - (OO--)</span>—take the negative value of F, subtract OO, then decrement OO
Step 2: The Chain Reaction of Macro Replacement
Every underscore<span>_</span> is replaced with<span>F-->00||-F-OO--;</span>, thus that beautiful “circle” is actually a series of complex decrement operations.
For the first line<span>_-_-_-_</span>, after replacement it becomes:
F-->00||-F-OO--;-F-->00||-F-OO--;-F-->00||-F-OO--;-F-->00||-F-OO--;
Step 3: Analyzing the Execution Process Line by Line
-
First Line (4 underscores):
-
Initial values: F=0, OO=0
-
First
<span>_</span>: After F–, F=-1, since -1>0 is false, execute<span>-F-OO--</span>(decrement OO) -
Subsequent three
<span>_</span>: Due to the preceding negative sign,<span>-F-->0</span>becomes a positive check, triggering short-circuit, OO no longer decrements -
Result: F=-4, OO=-1
Overall Statistics:
-
Total of 26 lines, 201 underscores
-
Each line’s first underscore causes OO to decrement, totaling 16 times
-
Final: F=-201, OO=-16
Step 4: The Final Chapter of Mathematical Magic
Program output:<span>4.*-F/OO/OO</span> = <span>4 * -(-201) / (-16) / (-16)</span> = <span>4 * 201 / 256</span> = <span>804 / 256</span> ≈3.141.Let’s debug and see if this is the result:
It meets our expectations
Conclusion: Between Order and Chaos
IOCCC reminds us that technology is not only about efficiency and functionality but also about aesthetics and creativity. While most programmers pursue clarity and maintainability in code, ICOCC participants explore the darkest corners of C language syntax, seeking forgotten language features and combining them into stunning digital artworks.
As computer scientist Donald Knuth said, “Science is what we understand, art is what understands us.” IOCCC is the ultimate embodiment of this philosophy—injecting warmth and human spirit into cold code.
“Programming should be fun, not just work.”—This may be the most important insight that IOCCC brings us.
If you’re interested, you can take a look at the winning codes from previous years of ICOOO,https://www.ioccc.org/years.html In fact, ICOOO’s code is the ultimate test for AI; the code is here, and everyone can analyze it with the AI available on the market, yielding unexpected results.
#include<stdio.h>
#define _ F–>00||-F-OO–;
float F=00,OO=00;main(){F_OO();printf(“%1.3f\n”,4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}