International Obfuscated C Code Contest: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>Cedar101
m Pi: syntaxhighlight
 
imported>SirWumpus
Remove request for more 2nd & 3rd party reference; believe recent updates have resolved this (I hope).
 
Line 1: Line 1:
{{short description|Computer programming contest}}
{{short description |Competition to produce pleasingly obscure C code}}
{{primary sources|date=November 2011}}
{{Infobox recurring event
{{Infobox recurring event
|name              = <!--Uses page name if omitted-->
|name              = <!--Uses page name if omitted-->
Line 20: Line 19:
|coordinates      = <!-- {{coord|LAT|LON|type:event|display=inline,title}} -->  
|coordinates      = <!-- {{coord|LAT|LON|type:event|display=inline,title}} -->  
|country          =  
|country          =  
|years_active      = 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015, 2018-2020
|years_active      = 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015, 2018–2020, 2024
|first            = {{start date|1984}}
|first            = {{start date|1984}}
|founders          = [[Landon Curt Noll]], Larry Bassel
|founders          = [[Landon Curt Noll]], Larry Bassel
|last              = 2020 <!-- Date of most recent event; if the event will not be held again, use {{End date|YYYY|MM|DD|df=y}} -->
|last              = 2024 <!-- Date of most recent event; if the event will not be held again, use {{End date|YYYY|MM|DD|df=y}} -->
|prev              =  
|prev              =  
|next              =  
|next              = Dec 2025
|participants      =  
|participants      =  
|activity          =  
|activity          =  
Line 39: Line 38:
|footnotes        =  
|footnotes        =  
}}
}}
The '''International Obfuscated C Code Contest''' (abbreviated '''IOCCC''') is a [[computer programming]] contest for [[Source code|code]] written in [[C (programming language)|C]] that is the most creatively [[obfuscated code|obfuscated]]. Held semi-annually, it is described as "celebrating [C's] syntactical opaqueness".<ref>{{cite journal |url=http://pcworld.co.nz/pcworld/pcw.nsf/how-to/beyond-the-command-line |access-date=2013-04-07 |title=Beyond the command line |journal=PC World New Zealand|last=Palmer|first=Geoff|date=November 1, 2004 |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 27th contest, held in 2020, was released in July 2020.<ref>{{cite web |url=https://www.ioccc.org/years-spoiler.html |title=Previous IOCCC Winners with spoilers |access-date=2023-05-01 |publisher=IOCCC}}</ref> Previous contests were held in the years 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015 and 2018–2020.
The '''International Obfuscated C Code Contest''' (abbreviated '''IOCCC''') is a [[computer programming]] contest for [[Source code|code]] written in [[C (programming language)|C]] that is the most creatively [[obfuscated code|obfuscated]] and held annually (when possible). It is described as "celebrating C's syntactical opaqueness".<ref>{{cite web |url=http://pcworld.co.nz/pcworld/pcw.nsf/how-to/beyond-the-command-line |access-date=2013-04-07 |title=Beyond the command line |work= [[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 28th contest, held in 2024/25, was announced<ref>{{cite web|url=https://www.theregister.com/2025/08/09/ioccc_2024/|title=The International Obfuscated C Code Contest is back for 2024|publisher=The Register|website=theregister.com|access-date=2025-09-12}}</ref>  by live stream 2 Aug 2025<ref>{{cite AV media|url=https://www.youtube.com/watch?v=UDzGwTalVAc|people=Landon Curt Noll, Leonid A. Broukhis, David McInnis|date=2025-08-02|title=IOCCC Awards Presentation and Source Code Reveal (4h30m35)}}</ref> in addition video segments for each of the 23 winners.<ref>{{cite av media|url=https://www.youtube.com/@OurFavoriteUniverse/videos|people=Landon Curt Noll, Leonid A. Broukhis, David McInnis|date=2025-08-02|editor=David McInnis|title=IOCCC28 winner segments}}</ref>


Entries are evaluated anonymously by a panel of judges. The judging process is documented in the competition guidelines<ref name=guidelines>{{cite web |url=https://www.ioccc.org/2015/guidelines.txt |title=2015 Guidelines |access-date=2023-05-01 |year=2015 |format=plain text |publisher=IOCCC}}</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.
Entries are evaluated anonymously by the current sitting judges, Leonid A. Broukhis & [[Landon Curt Noll]]. The judging process is documented in the competition guidelines<ref>{{cite web |url=https://www.ioccc.org/next/guidelines.html#judging-process|title=Judging Process|publisher= International Obfuscated C Code Contest | 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).
 
Previous contests were held in the years 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015, 2018–2020, and 2024.


==History==
==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=https://www.ioccc.org/faq.html |title=The FAQ |publisher=IOCCC |access-date=2023-05-01}}</ref> The contest itself was the topic of a quiz question in the 1993 Computer Bowl.<ref>[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 "Top Execs Fail To Compute Correctly"]. ''[[San Jose Mercury News]]'', California. May 15, 1993. p. 1A. Via [[Newsbank]]. {{subscription required}}</ref> After a hiatus of five years starting in 2006, the contest returned in 2011.<ref name=SJMerc11>{{cite web|url=https://www.pcworld.com/article/478306/obfuscated_code_contest_returns.html |title=Obfuscated Code Contest Returns |magazine=[[PC World]]|date=November 15, 2011|last=Jackson|first=Joab|access-date=2023-05-01}}</ref>
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=https://www.ioccc.org/faq.html#ioccc_start |title=How it started|publisher= International Obfuscated C Code Contest | website= IOCCC.org| date= |access-date=2025-08-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| page= 1A| via= [[Newsbank]]| url-access= subscription| url-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= https://www.pcworld.com/article/478306/obfuscated_code_contest_returns.html |title=Obfuscated Code Contest Returns |magazine=[[PC World]]|date=November 15, 2011|last=Jackson|first=Joab| publisher= |access-date=2023-05-01}}</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=https://www.drdobbs.com/architecture-and-design/there-must-be-contest/207404123 |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=2023-05-01}}</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=https://jacobfilipp.com/DrDobbs/articles/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=2025-08-27}}</ref>
 
In Don Libes' book<ref>{{cite book|publisher=Wiley|year=1993|title=Obfuscated C And Other Mysteries|author-first=Don|author-last=Libes|ISBN=0-471-57805-3|chapter=preface|pages=ix-x}}</ref> says:
<blockquote>...they will undoubtedly force you to expand your own mind when you study them.  And admittedly, some are just downright insane and only good for laughing at and making fun of.</blockquote>


==Rules==
==Rules==


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.
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>
 
{{quote box|text=Hacking the contest rules is a tradition.| author= —Landon Curt Noll, 2011<ref name=SJMerc11 />}}


{{Blockquote|text=Hacking the contest rules is a tradition. — Landon Curt Noll, 2011<ref name=SJMerc11 />}}
The Rules are often deliberately written with [[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 rules are often deliberately written with loopholes 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<ref>{{cite web|url=https://www.ioccc.org/1992/guidelines.txt|title=IOCCC 1992 Guidelines|publisher=International Obfuscated C Code Contest|website=IOCCC.org}}</ref> 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==
==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 some cases "spectacularly", according to ''Dr. Dobbs'',<ref>{{cite web |url=https://www.drdobbs.com/open-source/code-finessing/193104882?pgno=2 |title=Code Finessing |magazine=[[Dr. Dobb's Journal]]|author=Spinellis, Diomidis |date=October 5, 2006 |access-date=2023-05-01}}</ref> with one entry creating an 11-bit [[Arithmetic logic unit|ALU]] in the C preprocessor<ref name="cpp_abuse">[https://www.ioccc.org/2004/vik2.hint IOCCC 2004 Best Abuse of CPP]'' IOCCC. Retrieved 2023-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.
Entries often employ strange or unusual tricks, such as using the [[C preprocessor]] to do things it was not designed to do{{efn|In some cases "spectacularly", according to ''Dr. Dobbs'',<ref>{{cite web |url=https://jacobfilipp.com/DrDobbs/articles/DDJ/2006/0611/061001ds01/061001ds01.html |title=Code Finessing |magazine=[[Dr. Dobb's Journal]]| last= Spinellis| first= Diomidis |date=October 5, 2006 |access-date=2023-05-01}}</ref> with one entry creating an 11-bit [[Arithmetic logic unit|ALU]] in the C preprocessor<ref name= "cpp_abuse">{{cite web| url= https://www.ioccc.org/2004/vik2| title=2004/vik2 Best Abuse of CPP |publisher= International Obfuscated C Code Contest | website= IOCCC.org| date= | first= | last= |access-date= 2025-09-12}}</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, 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=smr.hint|url=https://www.ioccc.org/1994/smr.hint|access-date=2006-09-16|publisher=IOCCC|format=plain text}}</ref>
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, 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=1994/smr Worst abuse of the rules| url= https://www.ioccc.org/1994/smr/index.html |publisher= International Obfuscated C Code Contest | website= IOCCC.org |format=plain text |date=| access-date=2025-09-10}}</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.
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.
During the hiatus between 2020 and 2024 (the Great Fork Merge<ref>{{cite web|year=2024|title=Great Fork Merge| url= https://www.ioccc.org/2024#general-remarks-on-this-contest|publisher= International Obfuscated C Code Contest | website= IOCCC.org |format=plain text |date=| access-date=2025-09-10}}</ref>), many of the winners were updated for modern compilers, for example converting from K&R C to at least C89 syntax, except where doing so would have broken the obfuscation (the original versions are still available for viewing).  So with 2024, it should be possible to execute all the entries.  The web site documents and invites C programmers to fix those winners still with outstanding issues.<ref>{{cite web|title=IOCCC Fails to Compile or Run|year=2024|url=https://www.ioccc.org/faq.html#q-7.2-why-does-an-ioccc-entry-fail-to-compile-andor-run|publisher= International Obfuscated C Code Contest | website= IOCCC.org |format=plain text |date=| access-date=2025-09-10}}</ref><ref>{{cite web|title=IOCCC List of Issues|year=2024|url=https://www.ioccc.org/bugs.html|publisher= International Obfuscated C Code Contest | website= IOCCC.org |format=plain text |date=| access-date=2025-09-10}}</ref>


==Examples==
==Examples==
Within the code size limit of only a few kilobytes, contestants have managed to do complicated things – a 2004 winner turned out an operating system.<ref>{{cite web| url=https://www.ioccc.org/2004/gavin.hint |title=gavin.hint3 |year=2004 |format=plain text |publisher=IOCCC |access-date=2023-05-01}}</ref>
Within the code size limit of only a few kilobytes, contestants have managed to do complicated things – a 2004 winner turned out an operating system.<ref>{{cite web| url=https://www.ioccc.org/2004/gavin/ |title=2004/gavin Best of Show|year=2004 |format=plain text |publisher= International Obfuscated C Code Contest | website= IOCCC.org |access-date=2025-09-10}}</ref>


===Toledo Nanochess===
===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.
''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, the original being 1963 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=https://nanochess.org/chess3.html |title=Toledo Nanochess and Toledo Picochess}}</ref>
The source code for ''Toledo Nanochess'' and other engines is available.<ref>{{cite web |url=https://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 IOCCC18,<ref>{{cite web |url= https://www.ioccc.org/2005/toledo |title=2005/toledo Best Game|publisher=International Obfuscated C Code Contest | website= IOCCC.org |date= | accessdate=2025-09-12 }}</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=https://www.ioccc.org/winners.html#Oscar_Toledo_G. |title=Winners: The authors of winning IOCCC entries}}</ref>), it is heavily [[obfuscated code|obfuscated]].<ref>{{cite web |url=https://github.com/bormand/nanochess |title=Nanochess partially de-obfuscated version |website=[[GitHub]] |access-date=1 May 2023}}</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]]}}</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| 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>{{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=https://sourceforge.net/projects/smmax/files/sm-fide%20760.c/download |title=Super Micro FIDE 760}}</ref> There is also a smaller version of Toledo's engine, the ''Toledo Picochess'', consisting of 944 non-blank characters.
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>{{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=https://sourceforge.net/projects/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'''
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
B,i,y,u,b,I[411],*G=I,x=10,z=15,M=1e4;X(w,c,h,e,S,s){int t,o,L,E,d,O=e,N=-M*M,K
    typedef char ** C;
=78-h<<x,p,*g,n,*m,A,q,r,C,J,a=y?-x:x;y^=8;G++;d=w||s&&s>=h&&v 0,0)>M;do{_ o=I[
#define    F getchar())
p=O]){q=o&z^y _ q<7){A=q--&2?8:4;C=o-9&z?q["& .$  "]:42;do{r=I[p+=C[l]-64]_!w|p
#define H(z)*n++=z;
==w){g=q|p+a-S?0:I+S _!r&(q|A<3||g)||(r+1&z^y)>9&&q|A>2){_ m=!(r-2&7))P G[1]=O,
      #include        <setjmp.h>
K;J=n=o&z;E=I[p-a]&z;t=q|E-7?n:(n+=2,6^y);Z n<=t){L=r?l[r&7]*9-189-h-q:0 _ s)L
    #define v pain(0,0,0
+=(1-q?l[p/x+5]-l[O/x+5]+l[p%x+6]*-~!q-l[O%x+6]+o/16*8:!!m*9)+(q?0:!(I[p-1]^n)+
          #define Z while(
!(I[p+1]^n)+l[n&7]*9-386+!!g*99+(A<2))+!(E^y^9)_ s>h||1<s&s==h&&L>z|d){p[I]=n,O
                                                #define _ if(
[I]=m?*g=*m,*m=0:g?*g=0:0;L-=X(s>h|d?0:p,L-N,h+1,G[1],J=q|A>1?0:p,s)_!(h||s-1|B
#define o(d) (u[l]=0,l[d]=6^e,q=1e4>v,0),l[d]=0,u[l]=e^6,q)
-O|i-n|p-b|L<-M))P y^=8,u=J;J=q-1|A<7||m||!s|d|r|o<z||v 0,0)>M;O[I]=o;p[I]=r;m?
#define I(H,n) { _ r=l[x=H],!r|(r^e)<-1){ _ j=u[l],-7==r|6==r\
*m=*g,*g=0:g?*g=9^y:0;}_ L>N){*G=O _ s>1){_ h&&c-L<0)P L _!h)i=n,B=O,b=p;}N=L;}
){ n; e=~e; return 1e5- f; } u[l]=0,t=j+1,i=j-1; _!i&89<x)i\
n+=J||(g=I+p,m=p<O?g-3:g+2,*m<z|m[O-p]||I[p+=p-O]);}}}}Z!r&q>2||(p=O,q|A>2|o>z&
=j,t=6; _-1==t&30>x)t=j,i=-7; Z++i<t){ b=S; d=0; S&=63; \
!r&&++C*--A));}}}Z++O>98?O=20:e-O);P N+M*M&&N>-K+1924|d?N:0;}main(){Z++B<121)*G
a=((j^e)!=1?6!=(j^e)?O[32+x/10]-O[u/10+32]-q:(S|=6!=j?8\
++=B/x%x<2|B%x<2?7:B/x&4?0:*l++&31;Z B=19){Z B++<99)putchar(B%x?l[B[I]|16]:x)_
:1,2==u-x)*9+9*(x-u==2):(d=1==j?x-u:u-x)/8+!(!((x-u)%\
x-(B=F)){i=I[B+=(x-F)*x]&z;b=F;b+=(x-F)*x;Z x-(*G=F))i=*G^8^y;}else v u,5);v u,
10)|r)*99+(j==1?90<x:29>x)*(9*O[28+i]-288))+O[r+28\
1);}}</syntaxhighlight>
]*9-288+O[x%10+33]-f-O[33+u%10]; x[l]=i; S|=(21=\
=u|21==x)*2+(u==28|28==x)*4+(91==u|x==91)*16+32\
*(u==98|x==98)+(20==d)*64*x; a-=k>f?pain(a,f+1\
,M,k):0; _ i==c&u==h&!f&N&a>-1e4&x==y)longjm\
p(z,1); S=b; _!N|f&&(a>M||!f&a==M&&1&rand()\
)){ _!f){ _ k){ c=i; h=u; y=x; } } else _ \
L-a<N){ n; e=~e; u[l]=j; x[l]=r; return\
a; } M=a; } } x[l]=r; u[l]=j; n; } }
typedef int G; C kk; char J [ 78 ], O [ ]
=   "HRQAMS#-smaqrh[UTZYTU[|TBA("
"$#(ABT|ba`gg`ab8>GK[_`fFDZXEYR"        "L\t####"
"##B#A#@#G#F#E#D#K\t\3Zlv#tjm"        "\3J#tjm\3Pwb"
"ofnbwf\3Joofdbo\3)&`&`.&`&`"        "#+&g*\t"; G y,
c,h,e,S,*s,l[149]; jmp_buf z; G main(G L, C fa, C Na){
return pain(L, fa, Na, kk);}          G pain(G L,C fa,
C Na, C ka){G f=fa;       G N=Na; G k=ka;
G u=99,p,q,r,j,i,x                  ,t, a, b,d,M=-1e9
; char *n; if( *l){ e=~e; Z       u >21){ q= l[--u]^e;
_!-- q){ _!l[p=e?u-10:u+10]){  I(p,)_ e?u>80  & !l[p
-=10]:u<39&!l[p+=10])I(p,)} _ l[p=e?u-11:9+u]  )I(p,)
else _ u-1==S>>6){ l[u-1]=0; I(p,l[u-1]=-2^e);  } _ l[
p=e?u-9:11+u])I(p,)else _ S>>6==1+u){ l[1+u]=0; I(p,l
[1+u]=e^-2); } } _!--q){ n=O+41; Z++n<50+O)I(u+80-*n,
)} _ 0<q&4>q){  n=q==2?53+O:O+49; Z++n<O+(q!=1)*4+54
){ p=u; do I(p-=*n-80,)Z!p[l]); } } _ 4==q){ n=49+O
; Z++n<O+58)I(u-*n+80,)_ e&!(S&24)|!e&!(S&3)&&k&&
!l[u-2]&!l[u-1]&!l[u-3]&&o(u)&o(u-1)){ l[u-1]= 4
  ^e; l[u-4]=0; I(u-2,l[u-1]=0; l[u-4]=e^4); } _
  e&!(S&40)|!e&!(S&5)&&k&&!l[u+1]&!l[2+u]&&o(u)&
  o(1+u)){ l[u+1]=e^4; l[3+u]=0;   I(u+2,l[1+u
  ]=0; l[u+3]=4^e); } } } e=~e;  return M; }
    Z h<130){l[h]=-(21>h|98<h|2      >(h+1 )%
    10); O[h++]^=3; } n=O +14;       s=20+l; Z
    ++s<29+l){ 10[s]=1; 70[s]=~    ( * s = *
      n++ -+84); 60 [ s] =-2; } Z  n=J){ puts
      (58+O); u=19; Z++u<100){ H(32)_!( u%10
      ))H(32)H(O[7+l[u]])_(9+u)%10>7){ H(58
        -u/10)H(32)_ u&1)puts(n=J); } } puts
        (O+58); _-1e4 >v , 1)){ e=~e; puts
          (O+(v,0)> 1e4?e?90:82:96)); break
          ; } _ 1<L&e) { d=v,2+L); printf
            (O+114,h%10+64,58-h/10,y%10+64
            ,58 -y/10,d); } else{ putchar
              (62 ) ; h= (95 & F-44; c=l[h
                +=(56-F *10]; y=(95&F-44; y
                  +=(56-F*10; Z 10!=(u=(95
                    &F)){ c=5; Z--c>1&&u!=c
                      [O]); c=e^c-7; } } _!
                        setjmp(z)){ v+1,1);
                              puts(  106+
                                O); }   } Z
                                10!=
                                  F; }
</syntaxhighlight>


===Pi===
===Pi===
Below is a 1988 entry which calculates [[pi]] by looking at its own [[area]]:<ref>[https://www.ioccc.org/1988/westley.c "westley.c"], 5th International Obfuscated C Code Contest 1988</ref>
Below is a 1988 entry which calculates [[Pi]] by looking at its own [[area]]:.<ref>{{cite web| url= https://www.ioccc.org/1988/westley/|title= 1988/westley| year= 1988 |publisher= International Obfuscated C Code Contest | website= IOCCC.org | access-date= 2025-09-12}}</ref> This was written in the original [[The C Programming Language|K&R C]] (an update is available).


[[File:1998_IOCCC_Flight_simulator_screenshot.png|thumb|Pittsburgh scenery of the Flight simulator]]
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
#define _ -F<00||--F-OO--;
#define _ -F<00||--F-OO--;
Line 121: Line 181:
}
}
</syntaxhighlight>
</syntaxhighlight>
(This entry was written in [[K&R C]]; it does not work correctly in ANSI C without some changes.<ref>using gcc, compile with the following command line: <syntaxhighlight lang="console">$ gcc -traditional-cpp -o r r.c</syntaxhighlight> or <syntaxhighlight lang="console">$ gcc -E r.c | sed 's/- -/--/g' > r2.c ; gcc -o r2 r2.c</syntaxhighlight> (The source file is <code>r.c</code>){{Original research inline|date=April 2017}}</ref>)


===Flight simulator===
===Flight simulator===
Another example is the following flight simulator, the winner of the 1998 IOCCC,<ref name=":0">[https://blog.aerojockey.com/post/iocccsim Carl Banks' Blog: IOCCC Flight Simulator]. blog.aerojockey.com. Retrieved 2023-05-01.</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 |author=Skiena, Steven |pages=[https://archive.org/details/calculatedbetsco0000skie/page/152 152], 153 |publisher=The Mathematical Association of America|year=2001|isbn=978-0521009621}}</ref> and shown below:
Another example is a [[flight simulator]] using X Windows, the winner of the 1998 IOCCC,<ref name=":0">[https://blog.aerojockey.com/post/iocccsim Carl Banks' Blog: IOCCC Flight Simulator]. blog.aerojockey.com. Retrieved 2023-05-01.</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/page/152 |last= Skiena| first= Steven |pages=152–153 |publisher=The Mathematical Association of America |year= 2001 |isbn= 978-0521009621| access-date= 2025-09-12}}</ref> and shown below:


<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
Line 186: Line 244:
                               W*F-T*(.63*m-I*.086+m*E*19-D*25-.11*u
                               W*F-T*(.63*m-I*.086+m*E*19-D*25-.11*u
                               )/107e2)*_; D=cos(o); E=sin(o); } }
                               )/107e2)*_; D=cos(o); E=sin(o); } }
</syntaxhighlight>
[[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">
$ 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>
</syntaxhighlight>
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="console">$ cat pittsburgh.sc | ./banks </syntaxhighlight>


===Akari===
===Akari===
Below is a 2011 entry which downsamples [[Netpbm#PGM_example|PGM]], [[Netpbm#PPM_example|PPM]] images and ASCII art (of Akari from ''[[YuruYuri]]'') by Don, Yang:<ref>{{Cite web|title=Winners: The authors of winning IOCCC entries |url=https://www.ioccc.org/years.html#2011_akari |access-date=2023-05-01 |website=www.ioccc.org}}</ref>
Below is a 2011 entry which downsamples [[Netpbm#PGM example|PGM]], [[Netpbm#PPM example|PPM]] images and ASCII art (of Akari from ''[[YuruYuri]]'') by Don, Yang:<ref>{{Cite web|title=2011/akari Best of Show - Most Shrinkable |url= https://www.ioccc.org/2011/akari/|publisher=International Obfuscated C Code Contest | website= IOCCC.org  |access-date=2025-09-12}}</ref>


<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
Line 298: Line 346:
*[[Underhanded C Contest]]
*[[Underhanded C Contest]]
*[[Esoteric programming language]]
*[[Esoteric programming language]]
*[[Code golf]]
==Notes==
{{notelist}}


==Notes and references==
==References==
<references />
{{reflist}}


==External links==
==External links==
*{{official|https://www.ioccc.org/}}
*{{official website|https://www.ioccc.org/}}
*[https://hackaday.com/2020/07/10/mmm-obfuscated-shell-donuts/ Mmm… Obfuscated Shell Donuts, Sven Gregori]
*[https://www.youtube.com/watch?v=i55ptVQw1Kk LaurieWired - A Competition for Unreadable Code?]
*[https://www.youtube.com/watch?v=by53T03Eeds LaurieWired - This C code should be ILLEGAL. It's also fantastic.]
*[https://uguu.org/words/2015_10_01.html The World of Obfuscated, Esoteric, Artistic Programming" by Yusuke Endoh] (IOCCC winner x20)
*[https://nir-mo.github.io/ai/obfuscation/research/2023/07/25/Cracking-Complexity.html Cracking Complexity: ChatGPT's Exploration of Enigmatic C Code from the IOCCC]
*[https://www.oreilly.com/library/view/expert-c-programming/0131774298/ Expert C Programming, Peter van der Linden, ch. 8, p. 225 "Some Light Relief"] ISBN 0131774298


[[Category:C (programming language) contests]]
[[Category:C (programming language) contests]]

Latest revision as of 20:15, 18 November 2025

Template:Short description Template:Infobox recurring event The International Obfuscated C Code Contest (abbreviated IOCCC) is a computer programming contest for code written in C that is the most creatively obfuscated and held annually (when possible). It is described as "celebrating C's syntactical opaqueness".[1] The winning code for the 28th contest, held in 2024/25, was announced[2] by live stream 2 Aug 2025[3] in addition video segments for each of the 23 winners.[4]

Entries are evaluated anonymously by the current sitting judges, Leonid A. Broukhis & Landon Curt Noll. The judging process is documented in the competition guidelines[5] 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).

Previous contests were held in the years 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015, 2018–2020, and 2024.

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 for BSD.[6] The contest itself was the topic of a quiz question in the 1993 Computer Bowl.[7] After a hiatus of five years starting in 2006, the contest returned in 2011.[8]

Compared with other programming contests, the IOCCC is described as "not all that serious" by Michael Swaine, editor of Dr. Dobb's Journal.[9]

In Don Libes' book[10] says:

...they will undoubtedly force you to expand your own mind when you study them. And admittedly, some are just downright insane and only good for laughing at and making fun of.

Rules

The Rules[11] vary from year to year and are posted with a set of Guidelines[12] 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 BY-SA 4.0 International.[13]

<templatestyles src="Template:Quote_box/styles.css" />

Hacking the contest rules is a tradition.

—Landon Curt Noll, 2011[8]

Script error: No such module "Check for unknown parameters".

The Rules are often deliberately written with loopholes that contestants are encouraged to find and abuse.[12] Entries that take advantage of loopholes can cause the rules for the following year's contest to be adjusted.[12]

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[14] 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[15] 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)[16] 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 doTemplate:Efn 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, regarded as a high honor. An example is the world's shortest 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.[17]

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.

During the hiatus between 2020 and 2024 (the Great Fork Merge[18]), many of the winners were updated for modern compilers, for example converting from K&R C to at least C89 syntax, except where doing so would have broken the obfuscation (the original versions are still available for viewing). So with 2024, it should be possible to execute all the entries. The web site documents and invites C programmers to fix those winners still with outstanding issues.[19][20]

Examples

Within the code size limit of only a few kilobytes, contestants have managed to do complicated things – a 2004 winner turned out an operating system.[21]

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, the original being 1963 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.[22] Because Toledo Nanochess is based on Toledo's winning entry from IOCCC18,[23] it is heavily obfuscated.[24]

On February 2, 2014, the author published the book Toledo Nanochess: The commented source code, which contains the fully commented source code.[25]

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[26] – a derivative of Micro-Max – totaling 760 characters (spaces and newlines included).[27] There is also a smaller version of Toledo's engine, the Toledo Picochess, consisting of 944 non-blank characters.

    typedef char ** C;
#define    F getchar())
 #define H(z)*n++=z;
       #include        <setjmp.h>
    #define v pain(0,0,0
           #define Z while(
                                                 #define _ if(
#define o(d) (u[l]=0,l[d]=6^e,q=1e4>v,0),l[d]=0,u[l]=e^6,q)
#define I(H,n) { _ r=l[x=H],!r|(r^e)<-1){ _ j=u[l],-7==r|6==r\
){ n; e=~e; return 1e5- f; } u[l]=0,t=j+1,i=j-1; _!i&89<x)i\
=j,t=6; _-1==t&30>x)t=j,i=-7; Z++i<t){ b=S; d=0; S&=63; \
a=((j^e)!=1?6!=(j^e)?O[32+x/10]-O[u/10+32]-q:(S|=6!=j?8\
:1,2==u-x)*9+9*(x-u==2):(d=1==j?x-u:u-x)/8+!(!((x-u)%\
10)|r)*99+(j==1?90<x:29>x)*(9*O[28+i]-288))+O[r+28\
]*9-288+O[x%10+33]-f-O[33+u%10]; x[l]=i; S|=(21=\
=u|21==x)*2+(u==28|28==x)*4+(91==u|x==91)*16+32\
*(u==98|x==98)+(20==d)*64*x; a-=k>f?pain(a,f+1\
,M,k):0; _ i==c&u==h&!f&N&a>-1e4&x==y)longjm\
p(z,1); S=b; _!N|f&&(a>M||!f&a==M&&1&rand()\
)){ _!f){ _ k){ c=i; h=u; y=x; } } else _ \
L-a<N){ n; e=~e; u[l]=j; x[l]=r; return\
 a; } M=a; } } x[l]=r; u[l]=j; n; } }
typedef int G; C kk; char J [ 78 ], O [ ]
=   "HRQAMS#-smaqrh[UTZYTU[|TBA("
"$#(ABT|ba`gg`ab8>GK[_`fFDZXEYR"         "L\t####"
"##B#A#@#G#F#E#D#K\t\3Zlv#tjm"         "\3J#tjm\3Pwb"
"ofnbwf\3Joofdbo\3)&`&`.&`&`"         "#+&g*\t"; G y,
c,h,e,S,*s,l[149]; jmp_buf z; G main(G L, C fa, C Na){
return pain(L, fa, Na, kk);}          G pain(G L,C fa,
C Na, C ka){G f=fa;		      G N=Na; G k=ka;
G u=99,p,q,r,j,i,x                  ,t, a, b,d,M=-1e9
; char *n; if( *l){ e=~e; Z       u >21){ q= l[--u]^e;
_!-- q){ _!l[p=e?u-10:u+10]){   I(p,)_ e?u>80   & !l[p
-=10]:u<39&!l[p+=10])I(p,)} _ l[p=e?u-11:9+u]   )I(p,)
else _ u-1==S>>6){ l[u-1]=0; I(p,l[u-1]=-2^e);  } _ l[
p=e?u-9:11+u])I(p,)else _ S>>6==1+u){ l[1+u]=0; I(p,l
[1+u]=e^-2); } } _!--q){ n=O+41; Z++n<50+O)I(u+80-*n,
)} _ 0<q&4>q){  n=q==2?53+O:O+49; Z++n<O+(q!=1)*4+54
){ p=u; do I(p-=*n-80,)Z!p[l]); } } _ 4==q){ n=49+O
 ; Z++n<O+58)I(u-*n+80,)_ e&!(S&24)|!e&!(S&3)&&k&&
 !l[u-2]&!l[u-1]&!l[u-3]&&o(u)&o(u-1)){ l[u-1]= 4
  ^e; l[u-4]=0; I(u-2,l[u-1]=0; l[u-4]=e^4); } _
  e&!(S&40)|!e&!(S&5)&&k&&!l[u+1]&!l[2+u]&&o(u)&
   o(1+u)){ l[u+1]=e^4; l[3+u]=0;   I(u+2,l[1+u
   ]=0; l[u+3]=4^e); } } } e=~e;   return M; }
    Z h<130){l[h]=-(21>h|98<h|2       >(h+1 )%
    10); O[h++]^=3; } n=O +14;       s=20+l; Z
     ++s<29+l){ 10[s]=1; 70[s]=~    ( * s = *
      n++ -+84); 60 [ s] =-2; } Z  n=J){ puts
       (58+O); u=19; Z++u<100){ H(32)_!( u%10
       ))H(32)H(O[7+l[u]])_(9+u)%10>7){ H(58
        -u/10)H(32)_ u&1)puts(n=J); } } puts
         (O+58); _-1e4 >v , 1)){ e=~e; puts
          (O+(v,0)> 1e4?e?90:82:96)); break
           ; } _ 1<L&e) { d=v,2+L); printf
            (O+114,h%10+64,58-h/10,y%10+64
             ,58 -y/10,d); } else{ putchar
              (62 ) ; h= (95 & F-44; c=l[h
                +=(56-F *10]; y=(95&F-44; y
                   +=(56-F*10; Z 10!=(u=(95
                    &F)){ c=5; Z--c>1&&u!=c
                      [O]); c=e^c-7; } } _!
                         setjmp(z)){ v+1,1);
                               puts(   106+
                                O); }   } Z
                                 10!=
                                  F; }

Pi

Below is a 1988 entry which calculates Pi by looking at its own area:.[28] This was written in the original K&R C (an update is available).

File:1998 IOCCC Flight simulator screenshot.png
Pittsburgh scenery of the Flight simulator
#define _ -F<00||--F-OO--;
int F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
            _-_-_-_
       _-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
        _-_-_-_-_-_-_-_
            _-_-_-_
}

Flight simulator

Another example is a flight simulator using X Windows, the winner of the 1998 IOCCC,[29] as listed and described in Calculated Bets: Computers, Gambling, and Mathematical Modeling to Win (2001)[30] and shown below:

#include                                     <math.h>
#include                                   <sys/time.h>
#include                                   <X11/Xlib.h>
#include                                  <X11/keysym.h>
                                          double L ,o ,P
                                         ,_=dt,T,Z,D=1,d,
                                         s[999],E,h= 8,I,
                                         J,K,w[999],M,m,O
                                        ,n[999],j=33e-3,i=
                                        1E3,r,t, u,v ,W,S=
                                        74.5,l=221,X=7.26,
                                        a,B,A=32.2,c, F,H;
                                        int N,q, C, y,p,U;
                                       Window z; char f[52]
                                    ; GC k; main(){ Display*e=
 XOpenDisplay( 0); z=RootWindow(e,0); for (XSetForeground(e,k=XCreateGC (e,z,0,0),BlackPixel(e,0))
; scanf("%lf%lf%lf",y +n,w+y, y+s)+1; y ++); XSelectInput(e,z= XCreateSimpleWindow(e,z,0,0,400,400,
0,0,WhitePixel(e,0) ),KeyPressMask); for(XMapWindow(e,z); ; T=sin(O)){ struct timeval G={ 0,dt*1e6}
; K= cos(j); N=1e4; M+= H*_; Z=D*K; F+=_*P; r=E*K; W=cos( O); m=K*W; H=K*T; O+=D*_*F/ K+d/K*E*_; B=
sin(j); a=B*T*D-E*W; XClearWindow(e,z); t=T*E+ D*B*W; j+=d*_*D-_*F*E; P=W*E*B-T*D; for (o+=(I=D*W+E
*T*B,E*d/K *B+v+B/K*F*D)*_; p<y; ){ T=p[s]+i; E=c-p[w]; D=n[p]-L; K=D*m-B*T-H*E; if(p [n]+w[ p]+p[s
]== 0|K <fabs(W=T*r-I*E +D*P) |fabs(D=t *D+Z *T-a *E)> K)N=1e4; else{ q=W/K *4E2+2e2; C= 2E2+4e2/ K
 *D; N-1E4&& XDrawLine(e ,z,k,N ,U,q,C); N=q; U=C; } ++p; } L+=_* (X*t +P*M+m*l); T=X*X+ l*l+M *M;
  XDrawString(e,z,k ,20,380,f,17); D=v/l*15; i+=(B *l-M*r -X*Z)*_; for(; XPending(e); u *=CS!=N){
                                   XEvent z; XNextEvent(e ,&z);
                                       ++*((N=XLookupKeysym
                                         (&z.xkey,0))-IT?
                                         N-LT? UP-N?& E:&
                                         J:& u: &h); --*(
                                         DN -N? N-DT ?N==
                                         RT?&u: & W:&h:&J
                                          ); } m=15*F/l;
                                          c+=(I=M/ l,l*H
                                          +I*M+a*X)*_; H
                                          =A*r+v*X-F*l+(
                                          E=.1+X*4.9/l,t
                                          =T*m/32-I*T/24
                                           )/S; K=F*M+(
                                           h* 1e4/l-(T+
                                           E*5*T*E)/3e2
                                           )/S-X*d-B*A;
                                           a=2.63 /l*d;
                                           X+=( d*l-T/S
                                            *(.19*E +a
                                            *.64+J/1e3
                                            )-M* v +A*
                                            Z)*_; l +=
                                            K *_; W=d;
                                            sprintf(f,
                                            "%5d  %3d"
                                            "%7d",p =l
                                           /1.7,(C=9E3+
                              O*57.3)%0550,(int)i); d+=T*(.45-14/l*
                             X-a*130-J* .14)*_/125e2+F*_*v; P=(T*(47
                             *I-m* 52+E*94 *D-t*.38+u*.21*E) /1e2+W*
                             179*v)/2312; select(p=0,0,0,0,&G); v-=(
                              W*F-T*(.63*m-I*.086+m*E*19-D*25-.11*u
                               )/107e2)*_; D=cos(o); E=sin(o); } }

Akari

Below is a 2011 entry which downsamples PGM, PPM images and ASCII art (of Akari from YuruYuri) by Don, Yang:[31]

                                       /*
                                      +
                                     +
                                    +
                                    +
                                    [         >i>n[t
                                     */   #include<stdio.h>
                        /*2w0,1m2,]_<n+a m+o>r>i>=>(['0n1'0)1;
                     */int/**/main(int/**/n,char**m){FILE*p,*q;int        A,k,a,r,i/*
                   #uinndcelfu_dset<rsitcdti_oa.nhs>i/_*/;char*d="P%"   "d\n%d\40%d"/**/
                 "\n%d\n\00wb+",b[1024],y[]="yuriyurarararayuruyuri*daijiken**akkari~n**"
          "/y*u*k/riin<ty(uyr)g,aur,arr[a1r2a82*y2*/u*r{uyu}riOcyurhiyua**rrar+*arayra*="
       "yuruyurwiyuriyurara'rariayuruyuriyuriyu>rarararayuruy9uriyu3riyurar_aBrMaPrOaWy^?"
      "*]/f]`;hvroai<dp/f*i*s/<ii(f)a{tpguat<cahfaurh(+uf)a;f}vivn+tf/g*`*w/jmaa+i`ni("/**
     */"i+k[>+b+i>++b++>l[rb";int/**/u;for(i=0;i<101;i++)y[i*2]^="~hktrvg~dmG*eoa+%squ#l2"
     ":(wn\"1l))v?wM353{/Y;lgcGp`vedllwudvOK`cct~[|ju {stkjalor(stwvne\"gt\"yogYURUYURI"[
     i]^y[i*2+1]^4;/*!*/p=(n>1&&(m[1][0]-'-'||m[1][1]  !='\0'))?fopen(m[1],y+298):stdin;
      /*y/riynrt~(^w^)],]c+h+a+r+*+*[n>)+{>f+o<r<(-m]    =<2<5<64;}-]-(m+;yry[rm*])/[*
       */q=(n<3||!(m[2][0]-'-'||m[2][1]))?stdout /*]{     }[*/:fopen(m[2],d+14);if(!p||/*
       "]<<*-]>y++>u>>+r >+u+++y>--u---r>++i+++"  <)<      ;[>-m-.>a-.-i.++n.>[(w)*/!q/**/)
    return+printf("Can "  "not\x20open\40%s\40"    ""       "for\40%sing\n",m[!p?1:2],!p?/*
  o=82]5<<+(+3+1+&.(+  m  +-+1.)<)<|<|.6>4>-+(>    m-        &-1.9-2-)-|-|.28>-w-?-m.:>([28+
 */"read":"writ");for  (   a=k=u= 0;y[u];  u=2    +u){y[k++   ]=y[u];}if((a=fread(b,1,1024/*
,mY/R*Y"R*/,p/*U*/)/*          R*/ )>/*U{  */   2&& b/*Y*/[0]/*U*/=='P' &&4==/*"y*r/y)r\}
*/sscanf(b,d,&k,& A,&           i,  &r)&&        !   (k-6&&k -5)&&r==255){u=A;if(n>3){/*
]&<1<6<?<m.-+1>3> +:+ .1>3+++     .   -m-)      -;.u+=++.1<0< <; f<o<r<(.;<([m(=)/8*/
u++;i++;}fprintf   (q,    d,k,           u      >>1,i>>1,r);u  = k-5?8:4;k=3;}else
  /*]>*/{(u)=/*{   p> >u  >t>-]s                >++(.yryr*/+(    n+14>17)?8/4:8*5/
     4;}for(r=i=0  ;  ;){u*=6;u+=                (n>3?1:0);if    (y[u]&01)fputc(/*
      <g-e<t.c>h.a r  -(-).)8+<1.                 >;+i.(<)<     <)+{+i.f>([180*/1*
      (r),q);if(y[u   ]&16)k=A;if                               (y[u]&2)k--;if(i/*
      ("^w^NAMORI; {   I*/==a/*"                               )*/){/**/i=a=(u)*11
       &255;if(1&&0>=     (a=                                 fread(b,1,1024,p))&&
        ")]i>(w)-;} {                                         /i-f-(-m--M1-0.)<{"
         [ 8]==59/* */                                       )break;i=0;}r=b[i++]
            ;u+=(/**>>                                     *..</<<<)<[[;]**/+8&*
            (y+u))?(10-              r?4:2):(y[u]         &4)?(k?2:4):2;u=y[u/*
             49;7i\(w)/;}             y}ru\=*ri[        ,mc]o;n}trientuu ren (
             */]-(int)'`';}             fclose(          p);k= +fclose( q);
              /*] <*.na/m*o{ri{                       d;^w^;}  }^_^}}
               "   */   return  k-                -1+   /*\'   '-`*/
                     (   -/*}/   */0x01        );       {;{    }}
                            ;           /*^w^*/        ;}

If the program is run using its own source as the input, the result is:

$ ./akari akari.c 
                   
                  
                       int
            *w,m,_namori=('n');
         #include<stdio.h>/*;hrd"%  dnd4%"*/
     /**/int(y),u,r[128*2/*{y}icuhya*rr*rya=
   */];void/**/i(){putchar(u);}int/**/main(/*
  "(n"l)?M5{YlcpvdluvKct[j skao(tve"t"oYRYR"
   */int(w),char**n){for(m  =256;--m;r[m]/*
   "<*]y+u>r>u+y-u-r+i+" )   ;>m.a.i+n>()/q*/
 =25<(31&( m -1))||64-(  m    &192)||2>w?m:(2+
m/*"*,/U//     R/)/U *  & /Y/0/U/=P &=/"*/)\
&16?m-13 : 13+     m)   ;u=+10 ;for(;(m=/*
 *>/()/{ p u t-s        +(yy*+  n1>7?/:*/
   getchar ())+1         ;i()   ){if(10/*
   "wNMR;{ I/=/"               )/{*/==u*1
    )i();                      if(m-10){
      u=/*>                  *./<)[;*/8*
      4;i();       }u=r[    m];}return(
       * *n/*{i            ;w; }_}
          ( -*/ *00    )    ;  }
$ ./akari akari.c > ./akari.small
$ ./akari ./akari.small 
         
      wm_aoi(n)
  /*ity,,[2*/{}char*y=
 (")M{lpduKtjsa(v""YY"
 "*yuruyuri") ;main(/*
/",U/  R)U*  Y0U= ="/\
*/){puts    (y+ 17/*
 "NR{I="       ){/=*
   =*         */);/*
   **/{      ;;}}
$ 
$ ./akari ./akari.small > ./akari.smaller
$ ./akari ./akari.smaller
   main
(){puts("Y"
"U RU YU "\
"RI"   )/*
 */   ;}
$

See also

Notes

Template:Notelist

References

Template:Reflist

External links

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "citation/CS1".
  3. Script error: No such module "Citation/CS1".
  4. Template:Cite av media
  5. Script error: No such module "citation/CS1".
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".
  8. a b Script error: No such module "citation/CS1".
  9. Script error: No such module "Citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".
  12. a b c Script error: No such module "citation/CS1".
  13. Script error: No such module "citation/CS1".
  14. Script error: No such module "citation/CS1".
  15. Script error: No such module "citation/CS1".
  16. Script error: No such module "citation/CS1".
  17. Script error: No such module "citation/CS1".
  18. Script error: No such module "citation/CS1".
  19. Script error: No such module "citation/CS1".
  20. Script error: No such module "citation/CS1".
  21. Script error: No such module "citation/CS1".
  22. Script error: No such module "citation/CS1".
  23. Script error: No such module "citation/CS1".
  24. Script error: No such module "citation/CS1".
  25. Script error: No such module "citation/CS1".
  26. Script error: No such module "citation/CS1".
  27. Script error: No such module "citation/CS1".
  28. Script error: No such module "citation/CS1".
  29. Carl Banks' Blog: IOCCC Flight Simulator. blog.aerojockey.com. Retrieved 2023-05-01.
  30. Script error: No such module "citation/CS1".
  31. Script error: No such module "citation/CS1".