第 25 届国际 C 语言混乱代码大赛日前已成功举办,并公布获奖作品名单和代码。国际 C 语言混乱代码大赛(IOCCC, The International Obfuscated C Code Contest)是一项国际编程赛事,目的是写出最有创意的最让人难以理解的 C 语言代码,并限制在 4 kilobytes 以内。
之前常在该比赛中拿奖的浙大教授侯启明和 Google 的 Don Yang 再次获奖。侯启明这次写了一个 JSON转 SVG 饼状图的转换器,这也是他第五次获奖。Don Yang 则已经是第 8 次拿奖,这次写的是一个文本翻转和移位器(Text rotator and shifter)。
此外,著名开源项目 FFmpeg 和 QEMU 的作者 Fabrice Bellard 也参加了比赛并获奖,他的作品是一个图像压缩 demo 。
获奖名单一览:
一些有意思的代码如下:
anderson
#include<stdio.h>int a = 256;int main(){for(char b[a+a+a], *c=b ,*d=b+ a ,*e=b+a+a,*f,*g=fgets(e,(b[ a]=b [a+a] =a- a,a) , stdin);c[0]=a-a,f=c ,c=d ,d=e ,e=f, f= g,g =0,g = fgets(e,a+a -a+ a -a+a -a+ a- +a,stdin ),f +a-a ; pu\ tchar(+10)) { for( int h= 1,i=1,j, k=0 ,l =e[0]==32,m,n=0,o=c [ 0]== 32, p, q=0;d[q ];j=k,k=l,m=n,n=o,p=(j)+(k* 2 )+(l =(i = e[ q]&&i ) &&e[q +1 ]== 32,l*4)+(m* 8 )+(16* n )+( o =(h =c[ q]&&h)&&c[q+1]== 32,o* (16+16) )+0-0 +0, putchar(" ......"/*\ ( ||| ) |/|/ / */".')|)\\\\\\\\'""" "|||" "|||" "|'" ")|)\\\\\\\\'/|/(/""(/'/|/\\|\\|'/|/(/(/'/|/\\|\\|"[d[q++]==32?p:0]));}}/* typographic tributaries */
vokes
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef unsigned long W; static W*i,t,c,h,e,r,y,**a,*b,*o,*u,*n,*d,*s;enum _ {F=6 , I=7,N= 5 , D = 3 ,M=14 ,Y=0 , C=8,L = 1 , U = 9 , E=4}; static void (* _ ) ( ) ; static void*(*B)(),*T; static char m[0x3543],*Z;void *meltdown(void *p,size_t sz){ void *z=realloc(p,sz);if(!z||!sz)exit(n?y!=*n:I-F); return z;}void magic(W*p){W j;for(j=0;j<p[F];j++){W*v=T,Q= p[M+j];W*J=a[Q];if(N[J]==~0LU){ _ (Q);v=&I[J];}else if(J[D]) {v=&N[J];}if(v&&I[p]>*v)I[p]=*v;}}void cast(void){B(i,Y);}void spell(W G,W H){ _ (); _ (H); _ (H, G); _ (H); _ (G);}void witch( void){e=n[--E[b]];a[e][D]=0;if(b[C]>=U[b]){c=2*(b[C+L]?b[U]:1);o=B (d,c *sizeof*o);u=B(s,c*sizeof*o);b[M-N]=c;d=o;s=u;}d[b[N+D]++]=e;if (e>y)y=e;}void*brew(void*g,size_t l){puts(l?"":"Out of range.");exit (g?1:1);}void newt(W *p){F[p]=0;N[p]=I[p]=~F[p];}void bubble(W H){for (t=0;t<H;t++){s[i[d[H-t-1]]---1]=d[H-t-1];}}void boil(W G){for(t=0;t< G-1;t++){i[t+1]+=i[t];} _ =bubble;}void hex(W G,W H){for(t=0;t<H?G:Y;t++ ){i[d[t]]++;} _ =boil;}void nasal_demons(W G){for (t=Y;t<G;t++)i[t]=0; _ =hex;}void toil(void){i=B(i,y*sizeof*i); _ =nasal_demons;}void bat(W l) {C[b]=0; _ =witch;do _ ();while(e!=l);y++;if(!y)B=brew; _ =toil;spell (C [b],y);printf("%lu:",b[L]++);for(y=0;y<C[b];y++){printf(" %lu",s[y]);}y=0;puts("");}void potion(W l){W*p=a[l];if(p[N]!=~0LU)return;p[F+L]=h;p[N] =h;p[D]=1;h++;n[b[L+D]++]=l;if(E[b]==r){r*=2;n=B(n,r*sizeof*n);}magic(p) ;if(I[p]==p[N]){bat(l);} _ =potion;}void O(void){n=B(n,2*sizeof(*n));Y[n ]=r;if(a&&a[t]){r=2;b=a[t]; _ =potion;b[L+C]=b[L]^=b[L];E[b]=1;for(y=0;y <*n;y++){if(a[y]){ _ (y);}}} _ =cast;h=0;}void toad(W g,W j,W*l){o=B(a [g],((a[g]?a[g][F]:0)+j+M)*sizeof*o); _ =newt;if(!a[g]){ _ (o);}for(y= 0;y<j;y++){o[F[o]+F+C]=l[y];o[F]++;if(l[y]==g){continue;}u=B(a[l[y]] ,((a[l[y]]?a[l[y]][F]:Y)+M)*sizeof*u);if(!a[l[y]]){ _ (u);}a[l[y]] =u;}y=0;a[g]=o;}void familiar(void){W**w;e=r;if(!r){r=1;}while (r<=t){r*=2;if(!r){B=brew;break;}}w=B(a,r*sizeof*a);if(! Z){Z="\x5f";}for(y=e;y<r;y++){y[w]=T;}y=0;a=w; _ (Y[i] ,c-1,&i[1]);}void spectre(void ){if((W) *Z-060 >011){ return;} _ =toad ;i[c]=( W)atoi( Z);if(i[c]>t){t=i[c];}c++;if(c==h){i=B(i,2*h*sizeof*i);h*=2;}y=i[c-1];if((Z=strtok(T," \t"))){if(U>=(W)*Z-I*I+L) _ =spectre;}}int main(int argv,char**argc){h++;if(argc){T=argc[argv];} _:_ =O;i=(B=meltdown)(T,h*sizeof*i);while(*argc||Z){c=0;*argc=fgets(m,sizeof(m),stdin); _ =spectre;if(!* argc){Z=T;goto _ ;}Z=strtok(*argc,"\t ");while(Z&&(W)*Z-(M*D+F)<=U){ _ ( );}if(t>=r)familiar();else if(c>0){ _ (i[Y],c-1,&i[1]);}} _ ();goto _ ;}
Yang
#include/*nui*/<stdio.h>//;70/*#}r[3]op;f(p;ok})i[;k-r*?(rc&(o}nr**s*2)!}-mpi##extern int n0;typedef int x;x//i/eu2->uuo0uo=;nXfdx+1e8uOeh&k-x[e1(i)>{=eqa,niin,u,k,o,_,i=1;static char//[X]/f/t]:n=t-rxt+0f[=(-=+;t)*,aa!>1=dt0pzrpi(l)idtnnd[1125][0x401];x main(){if(//]* nu]O[nc-(ac=;odxx1k]}u)2ulr(=00+u2=ee&fos{n,*cci){for(n=0;1024>n;n++)//]Tkhng[0ur)[u[h>u)h1or];>]-=Or):=l*Ou);+r4poa&(=ep(qnllfor(u=0x0;u<1025;)d[n][u++]=64//[n;o]ua0=)a,<(=}X;no[n{8uo)=&{i]n)?fl!!g{u)=,uu/2;for(u=n=0////////]_#p^#onui[/u+}+?+r;d{r/X////////////c/(&if=-)p(l(xewt{1udd/4;EOF!=(o=////////////]#ebdl#ah[0}n/1()////////////////////1f(k1)*ion)thsO;,eegetchar())// //////]u#oh[,;/////////// //////;;)2nc={ci(=ck<<&&u<1024;// ///////////////// ////}{:t((ihl"Nh,ss)u+=o-10// ///////// ///2)nifaeYUaott?n<1024// ////,n(r(uLr,dd?d[n++// @@@ ///td(EuL*Xli][u]=o// @ @ ///+)Or;O,io,k=k<// @ @ ///)Fii;xb.n?n:k// @ @ ///"fi,.h,0:0// @@@ //)(n/h>:!(n// //;0t/>/=0);// //!/|//for(// 5 //=/*/% ;k--// 12 =q tni;)d[k// //))u//01][u// //1Ni//1]/*n/// //(Ui; >*/=!/*N// //=K~/ h*/1,/*UN/// //nqO~* .*/puts/*n//// //[/?,] o*/(d[k])/*u////// /////// //1*q[u i*/;}else{//t///////////// /////////// //,stup;d[0][0]++;puts(/*f///////// //]====[//////// //(N tni ti&/N/////.///s/It]]_bz8[// ///SHOUJO\vv/////////// //;}"jvo" su /U/////N///t}Ue]~J#phi[// //\SHUUMATSU|]_[//////// ///,"/utf" <ntt/fe=)|UI0{u;Nnu]^u#j[v// //,^^\RYOKOU/:)]a#p[.// ///"c!tj!xb" e/ n/ilI(|/(1ep)/ *>->IOCCC// //]^#dbi#`h#anuok^u#[// ///"S","/ttfm" d/eit{i(rl/r-s-"/e/]o[^^^^^!/////]hfhu[Qj:FfT]uhp)~[[// ///"iuspx!fsb!tho" unn;n)h=a({aIl0onnt//"jiu!fmcjefoJ","/zsbdt!fsb!tobnvI!" "///","~<1!osvufs<*2" lriqi(w!hf)h=e1trin//".;2;1;1+*432&25\*3,o)_6)92x\sbiduvq@1=v@2:.o@4:.o),v,1/>" cef ;n{Fci2cl}-iufi//"v*1?**)sbidufh>o))fmjix|*)ojbn!uoj<v-o!uoj31\?i/pjeut=fe" ntetli)Ot{3t;}lhte}//"vmdoj$","svpU!utbM!(tmsjH"{=]041[]6[u,n*rahc;q tni nretxe ixdn,aqEe)-u)}=Ced;//};0+nruter;)K(U;)++n*--;n*;K=n(rof{)(niam )O,K,U(N enifed# #e#iIm((g)Ip ;I"r#0.[(c)2018][cffc189a]*/"Nuko");}return+0;}//>h.oidts<edulcni#
所有获奖名单的源代码可点此查看。