fbpx
Wikipedia

International Obfuscated C Code Contest

The International Obfuscated C Code Contest (abbreviated IOCCC) is a computer programming contest for the most creatively obfuscated C code. Held annually, it is described as "celebrating [C's] syntactical opaqueness".[1] The winning code for the 27th contest, held in 2020, was released in July 2020.[2] Previous contests were held in the years 1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015 and 2018–2020.

International Obfuscated C Code Contest
The logo of the IOCCC
StatusActive
GenreCoding contest
FrequencyAnnually
Years active1984–1996, 1998, 2000, 2001, 2004–2006, 2011–2015, 2018-present
Inaugurated1984 (1984)
FoundersLandon Curt Noll, Larry Bassel
Websitewww.ioccc.org

Entries are evaluated anonymously by a panel of judges. The judging process is documented in the competition guidelines[3] 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.

History Edit

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

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

Rules Edit

Each year, the rules of the contest are published on the IOCCC website. All material is published under Creative Commons license BY-SA 3.0 Unported.[8] Rules vary from year to year and are posted with a set of guidelines that attempt to convey the spirit of the rules.

Hacking the contest rules is a tradition. — Landon Curt Noll, 2011[6]

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

Obfuscations employed Edit

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,[9] with one entry creating an 11-bit ALU in the C preprocessor[10]), 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. During several of the 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 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.[11]

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 Edit

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.[12]

Toledo Nanochess Edit

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.[13] Because Toledo Nanochess is based on Toledo's winning entry from the 18th IOCCC (Best Game[14]), it is heavily obfuscated.[15]

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

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

Source code excerpt

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 =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[ 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 ==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, 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 +=(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)+ !(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 [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 -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? *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+=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& !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 ++=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)_ 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, 1);}} 

Pi Edit

Below is a 1988 entry which calculates pi by looking at its own area:[19]

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

(This entry was written in K&R C; it does not work correctly in ANSI C without some changes.[20])

Flight simulator Edit

Another example is the following flight simulator, the winner of the 1998 IOCCC,[21] as listed and described in Calculated Bets: Computers, Gambling, and Mathematical Modeling to Win (2001)[22] 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); } } 
 
Pittsburgh scenery of the Flight simulator

This program needs the following command line on a Linux system to be compiled:[21]

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 

In order to run the binary file (banks) it has to be supplied with a .sc scenery file via stdin input:[21]

 cat pittsburgh.sc | ./banks 

Akari Edit

Below is a 2011 entry which downsamples an ascii image by Don, Yang:[23]

 /*  +  +  +  +  [ >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:

[root@host ~]# ./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 ) ; } [root@host ~]# ./akari akari.c > ./akari.small [root@host ~]# ./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=" ){/=*  =* */);/*  **/{ ;;}} [root@host ~]#  [root@host ~]# ./akari ./akari.small > ./akari.smaller [root@host ~]# ./akari ./akari.smaller  main (){puts("Y" "U RU YU "\ "RI" )/*  */ ;} [root@host ~]# 

See also Edit

Notes and references Edit

  1. ^ Palmer, Geoff (November 1, 2004). . PC World New Zealand. Archived from the original on February 10, 2013. Retrieved 2013-04-07.
  2. ^ "Previous IOCCC Winners with spoilers". IOCCC. Retrieved 2023-05-01.
  3. ^ a b c "2015 Guidelines" (plain text). IOCCC. 2015. Retrieved 2023-05-01.
  4. ^ "The FAQ". IOCCC. Retrieved 2023-05-01.
  5. ^ "Top Execs Fail To Compute Correctly". San Jose Mercury News, California. May 15, 1993. p. 1A. Via Newsbank. (subscription required)
  6. ^ a b Jackson, Joab (November 15, 2011). "Obfuscated Code Contest Returns". PC World. Retrieved 2023-05-01.
  7. ^ Swaine, Michael (May 1, 2008). "There Must be Contest". Dr. Dobb's Journal. Retrieved 2023-05-01.
  8. ^ IOCCC home page, footer, and in each hint.txt file
  9. ^ Spinellis, Diomidis (October 5, 2006). "Code Finessing". Dr. Dobb's Journal. Retrieved 2023-05-01.
  10. ^ IOCCC 2004 – Best Abuse of CPP IOCCC. Retrieved 2023-05-01.
  11. ^ "smr.hint" (plain text). IOCCC. 1994. Retrieved 2006-09-16.
  12. ^ "gavin.hint3" (plain text). IOCCC. 2004. Retrieved 2023-05-01.
  13. ^ "Toledo Nanochess and Toledo Picochess".
  14. ^ "Winners: The authors of winning IOCCC entries".
  15. ^ "Nanochess partially de-obfuscated version". GitHub. Retrieved 1 May 2023.
  16. ^ Toledo Gutiérrez, Oscar (2014). Toledo Nanochess: The commented source code. Lulu. ISBN 978-1-304-86437-6.
  17. ^ "Super Micro Chess Engine - Home Page - Extremely Compact C Source and Executable Program Size". smmax.sourceforge.net.
  18. ^ "Super Micro FIDE 760".
  19. ^ "westley.c", 5th International Obfuscated C Code Contest 1988
  20. ^ using gcc, compile with the following command line: gcc -traditional-cpp -o r r.c or gcc -E r.c | sed 's/- -/--/g' > r2.c ; gcc -o r2 r2.c (The source file is r.c)[original research?]
  21. ^ a b c Carl Banks' Blog: IOCCC Flight Simulator. blog.aerojockey.com. Retrieved 2023-05-01.
  22. ^ Skiena, Steven (2001). Calculated Bets: Computers, Gambling, and Mathematical Modeling to Win. The Mathematical Association of America. pp. 152, 153. ISBN 978-0521009621.
  23. ^ "Winners: The authors of winning IOCCC entries". www.ioccc.org. Retrieved 2023-05-01.

External links Edit

  • Official website

international, obfuscated, code, contest, this, article, relies, excessively, references, primary, sources, please, improve, this, article, adding, secondary, tertiary, sources, find, sources, news, newspapers, books, scholar, jstor, november, 2011, learn, whe. This article relies excessively on references to primary sources Please improve this article by adding secondary or tertiary sources Find sources International Obfuscated C Code Contest news newspapers books scholar JSTOR November 2011 Learn how and when to remove this template message The International Obfuscated C Code Contest abbreviated IOCCC is a computer programming contest for the most creatively obfuscated C code Held annually it is described as celebrating C s syntactical opaqueness 1 The winning code for the 27th contest held in 2020 was released in July 2020 2 Previous contests were held in the years 1984 1996 1998 2000 2001 2004 2006 2011 2015 and 2018 2020 International Obfuscated C Code ContestThe logo of the IOCCCStatusActiveGenreCoding contestFrequencyAnnuallyYears active1984 1996 1998 2000 2001 2004 2006 2011 2015 2018 presentInaugurated1984 1984 FoundersLandon Curt Noll Larry BasselWebsitewww ioccc orgEntries are evaluated anonymously by a panel of judges The judging process is documented in the competition guidelines 3 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 Contents 1 History 2 Rules 3 Obfuscations employed 4 Examples 4 1 Toledo Nanochess 4 2 Pi 4 3 Flight simulator 4 4 Akari 5 See also 6 Notes and references 7 External linksHistory EditThe 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 4 The contest itself was the topic of a quiz question in the 1993 Computer Bowl 5 After a hiatus of five years starting in 2006 the contest returned in 2011 6 Compared with other programming contests the IOCCC is described as not all that serious by Michael Swaine editor of Dr Dobb s Journal 7 Rules EditEach year the rules of the contest are published on the IOCCC website All material is published under Creative Commons license BY SA 3 0 Unported 8 Rules vary from year to year and are posted with a set of guidelines that attempt to convey the spirit of the rules Hacking the contest rules is a tradition Landon Curt Noll 2011 6 The rules are often deliberately written with loopholes that contestants are encouraged to find and abuse 3 Entries that take advantage of loopholes can cause the rules for the following year s contest to be adjusted 3 Obfuscations employed EditEntries 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 9 with one entry creating an 11 bit ALU in the C preprocessor 10 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 During several of the 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 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 11 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 EditWithin the code size limit of only a few kilobytes contestants have managed to do complicated things a 2004 winner turned out an operating system 12 Toledo Nanochess Edit Toledo Nanochess is a chess engine created by Mexican software developer Oscar Toledo Gutierrez 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 13 Because Toledo Nanochess is based on Toledo s winning entry from the 18th IOCCC Best Game 14 it is heavily obfuscated 15 On February 2 2014 the author published the book Toledo Nanochess The commented source code which contains the fully commented source code 16 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 17 a derivative of Micro Max totaling 760 characters spaces and newlines included 18 There is also a smaller version of Toledo s engine the Toledo Picochess consisting of 944 non blank characters Source code excerpt 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 78 h lt lt x p g n m A q r C J a y x x y 8 G d w s amp amp s gt h amp amp v 0 0 gt M do o I p O q o amp z y q lt 7 A q amp 2 8 4 C o 9 amp z q amp 42 do r I p C l 64 w p w g q p a S 0 I S r amp q A lt 3 g r 1 amp z y gt 9 amp amp q A gt 2 m r 2 amp 7 P G 1 O K J n o amp z E I p a amp z t q E 7 n n 2 6 y Z n lt t L r l r amp 7 9 189 h q 0 s L 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 I p 1 n l n amp 7 9 386 g 99 A lt 2 E y 9 s gt h 1 lt s amp s h amp amp L gt z d p I n O I m g m m 0 g g 0 0 L X s gt h d 0 p L N h 1 G 1 J q A gt 1 0 p s h s 1 B O i n p b L lt M P y 8 u J J q 1 A lt 7 m s d r o lt z v 0 0 gt M O I o p I r m m g g 0 g g 9 y 0 L gt N G O s gt 1 h amp amp c L lt 0 P L h i n B O b p N L n J g I p m p lt O g 3 g 2 m lt z m O p I p p O Z r amp q gt 2 p O q A gt 2 o gt z amp r amp amp C A Z O gt 98 O 20 e O P N M M amp amp N gt K 1924 d N 0 main Z B lt 121 G B x x lt 2 B x lt 2 7 B x amp 4 0 l amp 31 Z B 19 Z B lt 99 putchar B x l B I 16 x x B F i I B x F x amp z b F b x F x Z x G F i G 8 y else v u 5 v u 1 Pi Edit Below is a 1988 entry which calculates pi by looking at its own area 19 define F lt 00 F OO int F 00 OO 00 main F OO printf 1 3f n 4 F OO OO F OO This entry was written in K amp R C it does not work correctly in ANSI C without some changes 20 Flight simulator Edit Another example is the following flight simulator the winner of the 1998 IOCCC 21 as listed and described in Calculated Bets Computers Gambling and Mathematical Modeling to Win 2001 22 and shown below include lt math h gt include lt sys time h gt include lt X11 Xlib h gt include lt X11 keysym h gt 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 lt 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 lt fabs W T r I E D P fabs D t D Z T a E gt K N 1e4 else q W K 4E2 2e2 C 2E2 4e2 K D N 1E4 amp amp 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 amp z N XLookupKeysym amp z xkey 0 IT N LT UP N amp E amp J amp u amp h DN N N DT N RT amp u amp W amp h amp 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 amp G v W F T 63 m I 086 m E 19 D 25 11 u 107e2 D cos o E sin o nbsp Pittsburgh scenery of the Flight simulatorThis program needs the following command line on a Linux system to be compiled 21 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 In order to run the binary file banks it has to be supplied with a sc scenery file via stdin input 21 cat pittsburgh sc banks Akari Edit Below is a 2011 entry which downsamples an ascii image by Don Yang 23 gt i gt n t include lt stdio h gt 2w0 1m2 lt n a m o gt r gt i gt gt 0n1 0 1 int main int n char m FILE p q int A k a r i uinndcelfu dset lt rsitcdti oa nhs gt i char d P d n d 40 d n d n 00 wb b 1024 y yuriyurarararayuruyuri daijiken akkari n y u k riin lt ty uyr g aur arr a1r2a82 y2 u r uyu riOcyurhiyua rrar arayra yuruyurwiyuriyurara rariayuruyuriyuriyu gt rarararayuruy9uriyu3riyurar aBrMaPrOaWy f hvroai lt dp f i s lt ii f a tpguat lt cahfaurh uf a f vivn tf g w jmaa i ni i k gt b i gt b gt l rb int u for i 0 i lt 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 gt 1 amp amp m 1 0 m 1 1 0 fopen m 1 y 298 stdin y riynrt w c h a r n gt gt f o lt r lt m lt 2 lt 5 lt 64 m yry rm q n lt 3 m 2 0 m 2 1 stdout fopen m 2 d 14 if p lt lt gt y gt u gt gt r gt u y gt u r gt i lt lt gt m gt a i n gt w q return printf Can not x20 open 40 s 40 for 40 sing n m p 1 2 p o 82 5 lt lt 3 1 amp m 1 lt lt lt 6 gt 4 gt gt m amp 1 9 2 28 gt w m gt 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 gt U 2 amp amp b Y 0 U P amp amp 4 y r y r sscanf b d amp k amp A amp i amp r amp amp k 6 amp amp k 5 amp amp r 255 u A if n gt 3 amp lt 1 lt 6 lt lt m 1 gt 3 gt 1 gt 3 m u 1 lt 0 lt lt f lt o lt r lt lt m 8 u i fprintf q d k u gt gt 1 i gt gt 1 r u k 5 8 4 k 3 else gt u p gt gt u gt t gt s gt yryr n 14 gt 17 8 4 8 5 4 for r i 0 u 6 u n gt 3 1 0 if y u amp 01 fputc lt g e lt t c gt h a r 8 lt 1 gt i lt lt lt i f gt 180 1 r q if y u amp 16 k A if y u amp 2 k if i w NAMORI I a i a u 11 amp 255 if 1 amp amp 0 gt a fread b 1 1024 p amp amp i gt w i f m M1 0 lt 8 59 break i 0 r b i u gt gt lt lt lt lt lt 8 amp y u 10 r 4 2 y u amp 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 lt 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 root host akari akari c int w m namori n include lt stdio h gt 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 lt y u gt r gt u y u r i gt m a i n gt q 25 lt 31 amp m 1 64 m amp 192 2 gt w m 2 m U R U amp Y 0 U P amp amp 16 m 13 13 m u 10 for m gt p u t s yy n1 gt 7 getchar 1 i if 10 wNMR I u 1 i if m 10 u gt lt 8 4 i u r m return n i w 00 root host akari akari c gt akari small root host 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 root host root host akari akari small gt akari smaller root host akari akari smaller main puts Y U RU YU RI root host See also EditObfuscated Perl Contest Underhanded C Contest Esoteric programming languageNotes and references Edit Palmer Geoff November 1 2004 Beyond the command line PC World New Zealand Archived from the original on February 10 2013 Retrieved 2013 04 07 Previous IOCCC Winners with spoilers IOCCC Retrieved 2023 05 01 a b c 2015 Guidelines plain text IOCCC 2015 Retrieved 2023 05 01 The FAQ IOCCC Retrieved 2023 05 01 Top Execs Fail To Compute Correctly San Jose Mercury News California May 15 1993 p 1A Via Newsbank subscription required a b Jackson Joab November 15 2011 Obfuscated Code Contest Returns PC World Retrieved 2023 05 01 Swaine Michael May 1 2008 There Must be Contest Dr Dobb s Journal Retrieved 2023 05 01 IOCCC home page footer and in each hint txt file Spinellis Diomidis October 5 2006 Code Finessing Dr Dobb s Journal Retrieved 2023 05 01 IOCCC 2004 Best Abuse of CPPIOCCC Retrieved 2023 05 01 smr hint plain text IOCCC 1994 Retrieved 2006 09 16 gavin hint3 plain text IOCCC 2004 Retrieved 2023 05 01 Toledo Nanochess and Toledo Picochess Winners The authors of winning IOCCC entries Nanochess partially de obfuscated version GitHub Retrieved 1 May 2023 Toledo Gutierrez Oscar 2014 Toledo Nanochess The commented source code Lulu ISBN 978 1 304 86437 6 Super Micro Chess Engine Home Page Extremely Compact C Source and Executable Program Size smmax sourceforge net Super Micro FIDE 760 westley c 5th International Obfuscated C Code Contest 1988 using gcc compile with the following command line gcc traditional cpp o r r c or gcc E r c sed s g gt r2 c gcc o r2 r2 c The source file is r c original research a b c Carl Banks Blog IOCCC Flight Simulator blog aerojockey com Retrieved 2023 05 01 Skiena Steven 2001 Calculated Bets Computers Gambling and Mathematical Modeling to Win The Mathematical Association of America pp 152 153 ISBN 978 0521009621 Winners The authors of winning IOCCC entries www ioccc org Retrieved 2023 05 01 External links EditOfficial website Retrieved from https en wikipedia org w index php title International Obfuscated C Code Contest amp oldid 1175062259, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.