International Obfuscated C Code Contest: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Add: website. | Use this bot. Report bugs. | Suggested by BrownHairedGirl | Linked from User:BrownHairedGirl/Articles_with_bare_links | #UCB_webform_linked 230/1771
SirWumpus (talk | contribs)
Add some of the history of Rule 2 evolution.
 
(30 intermediate revisions by 19 users not shown)
Line 14:
|caption =
|status = Active
|genre = Coding contest
|datefrequency = =Semi-annually
|begins = {{start date|2018|12|26}}
|ends = {{start date|2019|03|15}}
|frequency = Annually
|venue =
|___location =
|coordinates = <!-- {{coord|LAT|LON|type:event|display=inline,title}} -->
|country =
|years_active = 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015, 2018-present2018–2020, 2024
|first = {{start date|1984}}
|founders = [[Landon Curt Noll]], Larry Bassel
|last = 2024 <!-- Date of most recent event; if the event will not be held again, use {{End date|YYYY|MM|DD|df=y}} -->
|prev =
|next = Dec 2025
|participants =
|activity =
Line 38 ⟶ 35:
|member =
|sponsor = <!-- | or sponsors = -->
|website = {{URL|https://www.ioccc.org/|www.ioccc.org}}
|current =
|footnotes =
}}
The '''International Obfuscated C Code Contest''' (abbreviated '''IOCCC''') is a [[computer programming]] contest for the most creatively [[obfuscatedSource code|obfuscatedcode]] written in [[C (programming language)|C]] that is the most creatively [[Sourceobfuscated code|codeobfuscated]]. Heldand held annually, it(when possible). It is described as "celebrating [C's] syntactical opaqueness".<ref>{{cite journalweb |url=http://pcworld.co.nz/pcworld/pcw.nsf/how-to/beyond-the-command-line |access-date=2013-04-07 |title=Beyond the command line |journalwork= [[PC World]] New Zealand| last=Palmer| first= Geoff| date=November 1, 2004| publisher= Fairfax Media, Fairfax New Zealand Limited |url-status=dead |archive-url= https://web.archive.org/web/20130210081342/http://pcworld.co.nz/pcworld/pcw.nsf/how-to/beyond-the-command-line |archive-date=February 10, 2013 }}</ref> The winning code for the 27th28th contest, held in 20202024/25, was releasedannounced inby live stream 2 JulyAug 20202025.<ref>{{cite web | url = httphttps://www.ioccc.org/years-spoiler.html | title = Previous IOCCC Winners |with access-datespoilers |publisher= 2014-01-08International |Obfuscated yearC =Code 2014Contest | publisher website= IOCCC | archive-url = https://web.archive.org/web/20131223151342/http://www.ioccc.org/years-spoiler.html | archiveaccess-date = 20132023-1205-23 | url-status = dead 01}}</ref> Previous contests were held in the years 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015, 2018–2020, and 2018–20202024.
 
Entries are evaluated anonymously by athe panelcurrent ofsitting judges, Leonid A. Broukhis & Landon Curt Noll. The judging process is documented in the competition guidelines<ref name=guidelines>{{cite web| |url = httphttps://www.ioccc.org/2015next/guidelines.txt html#judging-process| title =Judging 2015 Guidelines Process| access-date format= 2015-11-20HTML | year publisher= 2015International |Obfuscated format =C plainCode textContest | publisher website= IOCCC.org |access-date=2025-08-27}}</ref> and consists of elimination rounds. By tradition, no information is given about the total number of entries for each competition. Winning entries are awarded with a category, such as "Worst Abuse of the [[C preprocessor]]" or "Most Erratic Behavior", and then announced on the official IOCCC website. The contest states that being announced on the IOCCC website is the reward for winning (plus bragging rights).
 
==History==
 
The IOCCC was started by [[Landon Curt Noll]] and Larry Bassel in 1984 while employed at National Semiconductor's Genix porting group. The idea for the contest came after they compared notes with each other about some poorly written code that they had to fix, notably the [[Bourne shell]], which used macros to emulate [[ALGOL 68]] syntax, and a buggy version of [[finger (Unix)|finger]] for BSD.<ref>{{cite web | url =httphttps://www.ioccc.org/faq.html#ioccc_start | title=How it started|publisher= FAQInternational Obfuscated C Code Contest | publisherwebsite= IOCCC.org| date= |access-date = 20112025-1108-12 27}}</ref> The contest itself was the topic of a quiz question in the 1993 Computer Bowl.<ref>[{{cite news| url= http://nl.newsbank.com/nl-search/we/Archives?p_product=SJ&s_site=mercurynews&p_multi=SJ&p_theme=realcities&p_action=search&p_maxdocs=200&p_topdoc=1&p_text_direct-0=0EB71B1E74EA9019&p_field_direct-0=document_id&p_perpage=10&p_sort=YMD_date:D&s_trackval=GooglePM "|title= Top Execs Fail To Compute Correctly"].| first= | last= | work= ''[[San Jose Mercury News]]'',| place= California.| date= May 15, 1993.| p.page= 1A.| Viavia= [[Newsbank]].| url-access= {{subscription| requiredurl-status= dead| archiveurl= https://web.archive.org/web/20140808041942/http://nl.newsbank.com/nl-search/we/Archives?p_product=SJ&s_site=mercurynews&p_multi=SJ&p_theme=realcities&p_action=search&p_maxdocs=200&p_topdoc=1&p_text_direct-0=0EB71B1E74EA9019&p_field_direct-0=document_id&p_perpage=10&p_sort=YMD_date:D&s_trackval=GooglePM| archivedate= 2014-08-08| access-date= 2025-08-08}}</ref> After a hiatus of five years starting in 2006, the contest returned in 2011.<ref name=SJMerc11>{{cite web| url=http https://www.pcworld.com/article/243995478306/obfuscated_code_contest_returns.html |title=Obfuscated Code Contest Returns |magazine=[[PC World]]|date=November 15, 2011|last=Jackson|first=Joab| publisher= |access-date=20132023-0405-0701}}</ref>
 
Compared with other programming contests, the IOCCC is described as "not all that serious" by [[Michael Swaine (technical author)|Michael Swaine]], editor of ''[[Dr. Dobb's Journal]]''.<ref>{{cite journal |url=httphttps://www.drdobbsjacobfilipp.com/architecture-and-designDrDobbs/there-must-be-contestarticles/207404123 DDJ/2008/0806/080501ms01/080501ms01.html|title=There Must be Contest | first=Michael | last=Swaine | author-link=Michael Swaine (technical author) |journal=[[Dr. Dobb's Journal]]|date=May 1, 2008 |access-date=20132025-0408-07 27}}</ref>. Thought many IOCCC contestants may beg to differ.
 
==Rules==
 
The Rules<ref name=rules>{{cite web|url=https://www.ioccc.org/next/rules.html|title=Rules|publisher= International Obfuscated C Code Contest | website= IOCCC.org }}</ref> vary from year to year and are posted with a set of Guidelines<ref name=guidelines>{{cite web|url=https://www.ioccc.org/next/guidelines.html|title=Guidelines|publisher= International Obfuscated C Code Contest | website= IOCCC.org }}</ref> that attempt to convey additional enlightenment about the Rules. They are published on the IOCCC website. In addition all material including winning entries are published under [[Creative Commons license]] [[Share-alike|BY-SA]] 4.0 International.<ref>{{cite web| url= https://www.ioccc.org/license.html|title=IOCCC License Employed|publisher= International Obfuscated C Code Contest | website= IOCCC.org| date= | access-date= }}</ref>.
Each year, the rules of the contest are published on the IOCCC website. All material is published under [[Creative Commons license]] [[Share-alike|BY-SA]] 3.0 Unported.<ref>[https://www.ioccc.org/ IOCCC home page, footer], and in each hint.txt file</ref> Rules vary from year to year and are posted with a set of guidelines that attempt to convey the spirit of the rules.
 
{{Blockquotequotebox|text=Hacking the contest rules is a tradition.| author= Landon—Landon Curt Noll, 2011<ref name=SJMerc11 />}}
 
The rulesRules are often deliberately written with loopholes[[loophole]]s that contestants are encouraged to find and abuse.<ref name=guidelines /> Entries that take advantage of loopholes can cause the rules for the following year's contest to be adjusted.<ref name=guidelines />
 
The most significant of the Rules is Rule 2a & 2b (originally Rule 1), gross & net source size limits. During the life time of the contest, Rule 2 has evolved<ref>{{cite web|url=https://www.ioccc.org/faq.html#size_rule_history|title=Rule 2 Eras|publisher=International Obfuscated C Code Contest|website=IOCCC.org}}</ref> to accommodate subtle increases in source size limits. The 1984 contest started with a maximum source size of 512 bytes, which increased a few more times to 1536 bytes in 1991. In 1992, Rule 2 was split to distinguish between maximum overall size and maximum size ignoring white space and semicolons given certain conditions. In the early days, in order to make best use of space allowed, white space was stripped, often resulting in a compact blob of text, making it hard to read by humans, but served little purpose once passed through a C "pretty print" utility, which the judges did as part of their process. In 1992 the judges believed that form of obfuscation had played out and they wanted to encourage people to explore other ways of formatting the code, such as an ASCII image themed after the entry, or simply more traditionally indented C source. Around 2012/2013 the iocccsize(1)<ref>{{cite web|url=https://github.com/SirWumpus/iocccsize#history|title=iocccsize|publisher=Anthony C Howe|website=GitHub.com}}</ref> tool was adopted by the contest and tweaked to aid both contestants and judges apply the Rule 2b counting algorithm.
 
==Obfuscations employed==
 
Entries often employ strange or unusual tricks, such as using the [[C preprocessor]] to do things it was not designed to do (in{{efn|In some cases "spectacularly", according to ''Dr. Dobbs'',<ref>{{cite web |url=httphttps://www.drdobbs.com/open-source/code-finessing/193104882?pgno=2 |title=Code Finessing |magazine=[[Dr. Dobb's Journal]]|author last= Spinellis,| first= Diomidis |date=October 5, 2006 |access-date=20132023-0405-0701}}</ref> with one entry creating an 11-bit [[Arithmetic logic unit|ALU]] in the [[C preprocessor]]<ref name= "cpp_abuse">[http{{cite web| url= https://www.ioccc.org/2004/vik2.hint| title= IOCCC 2004 – Best Abuse of CPP]'' |publisher= International Obfuscated C Code Contest | website= IOCCC.org| Retrieveddate= 2013| first= | last= |access-04date= 2023-08.05-01}}</ref>),}} or avoiding commonly used constructs in the C programming language in favor of much more obscure ways of achieving the same thing.
 
Contributions have included source code formatted to resemble images, text, etc., after the manner of [[ASCII art]], preprocessor redefinitions to make code harder to read, and [[self-modifying code]]. In several years, an entry was submitted that required a new definition of some of the rules for the next year. This is, regarded as a high honor. An example is the world's shortest [[Quine (computing)|self-reproducing program]]. The entry was a program designed to output its own source code, and which had zero bytes of source code. When the program ran, it printed out zero bytes, equivalent to its source code.<ref>{{cite web|year=1994|title=iocc smr.hint| url= https://www.ioccc.org/1994/smr/index.hinthtml |access-datepublisher=2006-09-16 International Obfuscated C Code Contest |publisher website= IOCCC.org |format=plain text |date=| access-date=2025-08-05}}</ref>
 
In the effort to take obfuscation to its extremes, contestants have produced programs which skirt around the edges of C standards, or result in constructs which trigger rarely used code path combinations in compilers. As a result, several of the past entries may not compile directly in a modern compiler, and some may cause crashes.
 
==Examples==
Within the code size limit of only a few kilobytes, contestants have managed to do complicated things&nbsp; – a 2004 winner turned out an operating system.<ref>{{cite web| url = httphttps://www.ioccc.org/2004/gavin.hint | title = gavin.hint3 | year =2004 2004| format = plain text| |publisher= International Obfuscated C Code Contest | website= IOCCC|.org |access-date = 20072023-0305-01}}</ref>
 
===Toledo Nanochess===
''Toledo Nanochess'' is a [[chess engine]] created by Mexican software developer Oscar Toledo Gutiérrez, a five-time winner of the IOCCC. In accordance with IOCCC rules, it is 1255 characters long. The author claims that it is the world's smallest chess program written in C.
 
The source code for ''Toledo Nanochess'' and other engines is available.<ref>{{cite web | url = httphttps://www.nanochess.org/chess3.html| |title = Toledo Nanochess and Toledo Picochess| website= nanochess.org| publisher= | date= | access-date= }}</ref> Because ''Toledo Nanochess'' is based on Toledo's winning entry from the 18th IOCCC (Best Game<ref>{{cite web |url= https://www.ioccc.org/winners.html#Oscar_Toledo_G. |title=Winners: The authors of winning IOCCC entries |publisher=International Obfuscated C Code Contest | website= IOCCC.org |date= | accessdate= }}</ref>), it is heavily [[obfuscated code|obfuscated]].<ref>{{cite web |url=https://github.com/bormand/nanochess |title= Nanochess partially de-obfuscated version |website=[[GitHub]] |date= | publisher= |access-date=1 May 2023}}</ref>
Because ''Toledo Nanochess'' is based on Toledo's winning entry from the 18th IOCCC (Best Game<ref>{{cite web| url = http://www.ioccc.org/2005/whowon.html| title = Who won the 18th IOCCC}}</ref>), it is heavily [[obfuscated code|obfuscated]].<ref>{{cite web| url = https://github.com/bormand/nanochess| title = Nanochess partially de-obfuscated version| website = [[GitHub]]}}</ref>
 
On February 2, 2014, the author published the book ''Toledo Nanochess: The commented source code'', which contains the fully commented source code.<ref>{{Cite book|title=Toledo Nanochess: The commented source code|isbn=978-1-304-86437-6| first= Oscar| last= Toledo Gutiérrez| year= 2014| publisher=[[Lulu (company)|Lulu]]| isbn= 978-1-304-86437-6}}</ref>
 
As of February 7, 2010, it appears to be one of only two chess engines written in less than 2 kilobytes of C that are able to play full legal chess moves, along with ''Micro-Max'' by Dutch physicist H. G. Muller. In 2014 the 1 kilobyte barrier was broken by ''Super Micro Chess''<ref>http{{Cite web|url=https://smmax.sourceforge.net/|title=Super Micro Chess Engine - Home Page - Extremely Compact C Source and Executable Program Size|website=smmax.sourceforge.net}}</ref> – a derivative of Micro-Max – totaling 760 characters (spaces and newlines included).<ref>{{cite web | url = httphttps://downloads.sourceforge.net/projectprojects/smmax/files/sm-fide%20760.c|/download |title = Super Micro FIDE 760| website= sourceforge.net| publisher= | date= | access-date= }}</ref> There is also a smaller version of Toledo's engine, the ''Toledo Picochess'', consisting of 944 non-blank characters.
 
'''Source code excerpt'''
Line 100 ⟶ 98:
 
===Pi===
Below is a 1988 entry which calculates [[pi]] by looking at its own [[area]]:<ref>[http{{cite web| url= https://www0.uswww.ioccc.org/1988/westley.c "|title= westley.c"],| 5thyear= 1988 |publisher= International Obfuscated C Code Contest 1988| {{Webarchive|urlwebsite=https://web.archive IOCCC.org/web/20131022114748/http://www0.us.ioccc.org/1988/westley.c | access-date=2013-10-22 }} ). IOCCC.</ref>
 
<syntaxhighlight lang="c">
Line 125 ⟶ 123:
</syntaxhighlight>
 
(This entry was written in [[K&R C]]; it does not work correctly in ANSI C without some changes.<ref>usingUsing gcc, compile with the following command line: <codesyntaxhighlight lang="console">$ gcc -traditional-cpp -o r r.c</codesyntaxhighlight> or <codesyntaxhighlight lang="console">$ gcc -E r.c | sed 's/- -/--/g' > r2.c ; gcc -o r2 r2.c</codesyntaxhighlight> (The source file is <code>r.c</code>){{Original research inline|date=April 2017}}</ref>)
 
===Flight simulator===
Another example is the following flight simulator, the winner of the 1998 IOCCC,<ref name=":0">[httphttps://wwwblog.aerojockey.com/softwarepost/ioccc/index.htmliocccsim Carl Banks' Blog: IOCCC Flight Simulator]. blog.aerojockey.com. Retrieved 20132023-0405-0801.</ref> as listed and described in ''Calculated Bets: Computers, Gambling, and Mathematical Modeling to Win'' (2001)<ref>{{cite book |title= Calculated Bets: Computers, Gambling, and Mathematical Modeling to Win |url= https://archive.org/details/calculatedbetsco0000skie |url-access= registration |authorlast= Skiena,| first= Steven |pages=[https://archive.org/details/calculatedbetsco0000skie/page/152 152], 153 |publisher=The Mathematical Association of America |year= 2001 |isbn= 978-0521009621| access-date= }}</ref> and shown below:
 
<syntaxhighlight lang="c">
Line 192 ⟶ 190:
[[File:1998_IOCCC_Flight_simulator_screenshot.png|thumb|Pittsburgh scenery of the Flight simulator]]
This program needs the following command line on a Linux system to be compiled:<ref name=":0" />
<syntaxhighlight lang="console">
<pre>
$ cc banks.c -o banks -DIT=XK_Page_Up -DDT=XK_Page_Down \
-DUP=XK_Up -DDN=XK_Down -DLT=XK_Left -DRT=XK_Right \
-DCS=XK_Return -Ddt=0.02 -lm -lX11 -L/usr/X11R6/lib
</syntaxhighlight>
</pre>
 
In order to run the binary file ({{code|banks}}) it has to be supplied with a {{code|.sc}} scenery file via [[standard input|{{code|stdin}}]] input:<ref name=":0" />
<syntaxhighlight lang=shell"console">$ cat pittsburgh.sc | ./banks </syntaxhighlight>
 
===Akari===
Below is a 2011 entry which downsamples an[[Netpbm#PGM_example|PGM]], [[Netpbm#PPM_example|PPM]] images and ASCII art (of Akari asciifrom image''[[YuruYuri]]'') by Don, Yang:<ref>{{Cite web|title=IndexWinners: The authors of /2011/akariwinning IOCCC entries |url=http https://www.ioccc.org/2011/akari/years.html#2011_akari|access-datepublisher=2020-09-18International Obfuscated C Code Contest | website=www.ioccc IOCCC.org |access-date=2023-05-01}}</ref>
 
<syntaxhighlight lang="c">
Line 250 ⟶ 248:
</syntaxhighlight>
 
If the program is run using its own source as the input, the result is:
<syntaxhighlight lang="c">
[root@host ~]#$ ./akari akari.c
Line 273 ⟶ 272:
* *n/*{i ;w; }_}
( -*/ *00 ) ; }
[root@host ~]#$ ./akari akari.c > ./akari.small
[root@host ~]#$ ./akari ./akari.small
wm_aoi(n)
Line 285 ⟶ 284:
=* */);/*
**/{ ;;}}
$
[root@host ~]#
[root@host ~]#$ ./akari ./akari.small > ./akari.smaller
[root@host ~]#$ ./akari ./akari.smaller
main
(){puts("Y"
Line 293 ⟶ 292:
"RI" )/*
*/ ;}
$
[root@host ~]#
</syntaxhighlight>
 
Line 301 ⟶ 300:
*[[Esoteric programming language]]
 
==Notes and references==
{{notelist}}
<references />
 
==References==
{{reflist}}
 
==External links==
Line 308 ⟶ 310:
 
[[Category:C (programming language) contests]]
[[Category:Computer humorhumour]]
[[Category:Software obfuscation]]
[[Category:Ironic and humorous awards]]