home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / ioccc / part05 < prev    next >
Encoding:
Internet Message Format  |  1988-03-14  |  23.6 KB

  1. Subject:  v14i005:  International Obfuscated C Code Contest, Part05/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Landon Curt Noll <chongo@uts.amdahl.com>
  7. Posting-number: Volume 14, Issue 5
  8. Archive-name: ioccc/part05
  9.  
  10. # This is a shell archive.  Remove anything before this line, then
  11. # unpack it by saving it in a file and typing "sh file".  (Files
  12. # unpacked will be owned by you and have default permissions.)
  13. #
  14. # This archive contains:
  15. # ./1987/Makefile ./1987/README ./1987/biggar.c ./1987/biggar.hint 
  16. # ./1987/heckbert.c ./1987/heckbert.hint ./1987/hines.c ./1987/hines.hint 
  17. # ./1987/korn.c ./1987/korn.hint ./1987/lievaart.c ./1987/lievaart.hint 
  18. # ./1987/lievaart2.c ./1987/rules ./1987/wall.c ./1987/wall.hint 
  19. # ./1987/westley.c ./1987/westley.hint
  20.  
  21. echo mkdir ./1987
  22. mkdir ./1987
  23. echo x - ./1987/Makefile
  24. sed -e 's/^X//' > "./1987/Makefile" << '//E*O*F ./1987/Makefile//'
  25. X# %W% %G% %U%
  26. X#
  27. X# 1987 makefile
  28. X
  29. XSHELL=/bin/sh
  30. XWINNERS=heckbert wall westley hines korn biggar lievaart lievaart2
  31. X
  32. X# for System V style systems
  33. XOPSYS=-Dindex=strchr
  34. X# for BSD style systems
  35. X#OPSYS=
  36. X
  37. Xall: ${WINNERS}
  38. X
  39. Xheckbert: heckbert.c
  40. X    cc ${OPSYS} $? -o $@
  41. Xwall: wall.c
  42. X    cc $? -o $@
  43. Xwestley: westley.c
  44. X    cc $? -o $@
  45. Xhines: hines.c
  46. X    cc $? -o $@
  47. Xkorn: korn.c
  48. X    cc $? -o $@
  49. Xbiggar: biggar.c
  50. X    cc -DC="R>0" -DI="if(T)O" -DO="c=write(1,&c,1);" \
  51. X        -DP="main(){X}" -DR="read(0,&c,1)" -DT="c!=015" \
  52. X        -DW="while(C)I" -DX="char c;W" $? -o $@
  53. Xlievaart: lievaart.c
  54. X    cc $? -o $@
  55. X# not an official entry
  56. Xlievaart2: lievaart2.c
  57. X    cc $? -o $@
  58. X
  59. Xclean:
  60. X    rm -f core
  61. Xclobber: clean
  62. X    rm -f ${WINNERS}
  63. Xinstall: all
  64. X    @echo are you kidding'??'
  65. //E*O*F ./1987/Makefile//
  66.  
  67. echo x - ./1987/README
  68. sed -e 's/^X//' > "./1987/README" << '//E*O*F ./1987/README//'
  69. X1987 marked the "The Fourth International Obfuscated C Code Contest"
  70. X
  71. XThe rules for 1987 suggested categories even more categories than
  72. Xin 1986.  Hints for what to do and not to do were also given
  73. Xin the rules.  For example, a simple excessive abuse of /lib/cpp
  74. Xwas discouraged unless the abuse was unusual.  The mailboxes
  75. Xfor the contest were moved from nsc to amdahl.  The practice
  76. Xof posting a preliminary set of rules for the next year was started
  77. Xthis year.
  78. X
  79. XRules and results were posted to comp.lang.c, comp.unix.wizards with
  80. Xan announcement in news.announce.important.  Micro/Systems Journal
  81. Xpublished the 1987 winners.  Mark Horton included a version of the 1987
  82. Xwinners in an appendix of his C book.  The first announcement of
  83. Xwinners at the Summer 87 Usenix was helped by a small fly that
  84. Xdanced all over the foils.
  85. //E*O*F ./1987/README//
  86.  
  87. echo x - ./1987/biggar.c
  88. sed -e 's/^X//' > "./1987/biggar.c" << '//E*O*F ./1987/biggar.c//'
  89. XP;
  90. //E*O*F ./1987/biggar.c//
  91.  
  92. echo x - ./1987/biggar.hint
  93. sed -e 's/^X//' > "./1987/biggar.hint" << '//E*O*F ./1987/biggar.hint//'
  94. XBest Abuse of the Rules: <sdcrdcf!markb> Mark Biggar
  95. X
  96. X    Mark Biggar
  97. X    UNiSYS - System Development Group, Santa Monica
  98. X    2525 Colorado AV MD 91-01
  99. X    Santa Monica, CA
  100. X    90406
  101. X
  102. XCompile with:
  103. X
  104. X    cc -DC="R>0" -DI="if(T)O" -DO="c=write(1,&c,1);" -DP="main(){X}"\
  105. X    -DR="read(0,&c,1)" -DT="c!=015" -DW="while(C)I" -DX="char c;W" markb.c
  106. X
  107. XPasses BSD and UTS lint.  At least one version of lint is thrown into
  108. Xan infinite loop by this entry.
  109. X
  110. XTry:  ... | markb | od -c    (remember to compile as indicated above)
  111. X
  112. XBy changing the compile line you can make this program do anything you
  113. Xwant.  This is a very efficient way to transfer source, though it
  114. Xincreases the size of Makefiles.
  115. X
  116. XWith only slight variations, this program can be set to many uses.
  117. XConsider how easy it would be to release Un*x source in this form;
  118. Xso what if the make files grow a little!  :-) 
  119. X
  120. XOne vendor's lint got hung in an infinite loop over this entry!
  121. X
  122. XFYI:  We will let Mark get away with this truely sick entry this time, but 
  123. X      for the future on we have placed a limit on the size of a compile line.
  124. X
  125. XAlso see our comment in Larry Wall's entry regarding Mark's contribution.
  126. //E*O*F ./1987/biggar.hint//
  127.  
  128. echo x - ./1987/heckbert.c
  129. sed -e 's/^X//' > "./1987/heckbert.c" << '//E*O*F ./1987/heckbert.c//'
  130. X#include <ctype.h>
  131. X#include <stdio.h>
  132. X#define _ define
  133. X#_ A putchar
  134. X#_ B return
  135. X#_ C index
  136. Xchar*r,c[300001],*d=">=<=!===||&&->++-->><<",*i,*l,*j,*m,*k,*n,*h,*y;e,u=1,v,w,
  137. Xf=1,p,s,x;main(a,b)char**b;{p=a>1?atoi(b[1]):79;r=c+read(0,j=l=i=c,300000);v=g(
  138. Xj,&m);for(k=m;v!=2;j=k,m=n,v=w,k=m){w=g(k,&n);if(v==1&&m-j==1&&*j==35)e&&A(10),
  139. Xe=f=0;if(!f&&v==3&&(char*)C(j,10)<m)A(10),e=0,f=1;else if(v>2&&(u||w)&&(f||u)&&
  140. X(l-i>1||*i!=61||n-k>1||!C("-*&",*k)))continue;else if(v==3)if(f&&e+1+n-k>p&&e)A
  141. X(10),e=0;else A(32),e++;else{if(f&&e+m-j>p&&e)A(10),e=0;e+=m-j;k=j;while(k<m)A(
  142. X*k++);}i=j;l=m;u=v;}e&&A(10);}g(j,m)char*j,**m;{if(j>=r)B*m=j,2;s=isdigit(*j)||
  143. X*j==46&&isdigit(j[1]);for(h=j;h<r;h++)if(!isalnum(*h)&&*h!=95&&(!s||*h!=46)&&(!
  144. Xs||h[-1]!=101&&h[-1]!=69||!C("+-",*h)))break;if(h>j)B*m=h,0;x=1;for(h=j;h<r&&C(
  145. X" \t\n",*h);h++);if(h>j)h--,x=3;if(*j==34||*j==39)for(h=j+1;h<r&&*h!=*j;h++)if(
  146. X*h==92)h++;for(y=d;*y&&strncmp(y,j,2);y+=2);if(*y)h=j+1;if(!strncmp("/*",j,2)){
  147. Xh=j+2;while(*++h!=42||*++h!=47);x=4;}*m=h+1;B x;}
  148. //E*O*F ./1987/heckbert.c//
  149.  
  150. echo x - ./1987/heckbert.hint
  151. sed -e 's/^X//' > "./1987/heckbert.hint" << '//E*O*F ./1987/heckbert.hint//'
  152. XBest Obfuscator of Programs: <pixar!ph> Paul Heckbert
  153. X
  154. X    Paul Heckbert
  155. X    Pixar
  156. X
  157. XTry: ph 40 < ph.c > foo.c; cc foo.c -o ph
  158. X     ph 20 < a_C_prog.c > bar.c; cc bar.c
  159. X
  160. XThe judges used this program to fold up very long lines which the
  161. XBSD fold(1) was unable to process.  This program has been added
  162. Xto the contest tool chest.
  163. X
  164. XOn System V systems, compile with: -Dindex=strchr.
  165. XTo compile on a 16 bit machine, change 300000's to 30000.
  166. //E*O*F ./1987/heckbert.hint//
  167.  
  168. echo x - ./1987/hines.c
  169. sed -e 's/^X//' > "./1987/hines.c" << '//E*O*F ./1987/hines.c//'
  170. X#include <stdio.h>
  171. X#include <malloc.h>
  172. Xmain(togo,toog)
  173. Xint togo;
  174. Xchar *toog[];
  175. X{char *ogto,   tgoo[80];FILE  *ogot;  int    oogt=0, ootg,  otog=79,
  176. Xottg=1;if (    togo==  ottg)   goto   gogo;  goto    goog;  ggot:
  177. Xif (   fgets(  tgoo,   otog,   ogot)) goto   gtgo;   goto   gott;
  178. Xgtot:  exit(); ogtg: ++oogt;   goto   ogoo;  togg:   if (   ootg > 0)
  179. Xgoto   oggt;   goto    ggot;   ogog:  if (  !ogot)   goto   gogo;
  180. Xgoto   ggto;   gtto:   printf( "%d    goto   \'s\n", oogt); goto
  181. Xgtot;  oggt:   if (   !memcmp( ogto, "goto", 4))     goto   otgg;
  182. Xgoto   gooo;   gogo:   exit(   ottg); tggo:  ootg=   strlen(tgoo);
  183. Xgoto   tgog;   oogo: --ootg;   goto   togg;  gooo: ++ogto;  goto
  184. Xoogo;  gott:   fclose( ogot);  goto   gtto;  otgg:   ogto=  ogto +3;
  185. Xgoto   ogtg;   tgog:   ootg-=4;goto   togg;  gtgo:   ogto=  tgoo;
  186. Xgoto   tggo;   ogoo:   ootg-=3;goto   gooo;  goog:   ogot=  fopen(
  187. Xtoog[  ottg],  "r");   goto    ogog;  ggto:  ogto=   tgoo;  goto
  188. Xggot;}
  189. //E*O*F ./1987/hines.c//
  190.  
  191. echo x - ./1987/hines.hint
  192. sed -e 's/^X//' > "./1987/hines.hint" << '//E*O*F ./1987/hines.hint//'
  193. XWorst Style: <grebyn!avalon> Spencer Hines
  194. X
  195. X    Spencer Hines
  196. X    OnLine Computer Systems
  197. X    4200 Farragut Street
  198. X    Hyattsville, MD
  199. X    20781
  200. X    USA
  201. X
  202. XTry:  avalon avalon.c
  203. X
  204. XThis program was designed to maximize the bother function for
  205. Xstructured programmers.  This program takes goto statements to their
  206. Xlogical conclusion.  The layout and choice of names are classic.
  207. X
  208. XWe consider this to be a beautiful counter-example for Frank Rubin's
  209. Xletter to ACM form titled: `` "GOTO Considered Harmful" Considered Harmful ''.
  210. XSee the Communications of the ACM, March 1987, Page 195-196.
  211. //E*O*F ./1987/hines.hint//
  212.  
  213. echo x - ./1987/korn.c
  214. sed -e 's/^X//' > "./1987/korn.c" << '//E*O*F ./1987/korn.c//'
  215. X    main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}
  216. //E*O*F ./1987/korn.c//
  217.  
  218. echo x - ./1987/korn.hint
  219. sed -e 's/^X//' > "./1987/korn.hint" << '//E*O*F ./1987/korn.hint//'
  220. XBest One Liner: <ulysses!dgk> David Korn
  221. X
  222. X    David Korn
  223. X    AT&T Bell Labs
  224. X    MH 3C-526B, AT&T Bell Labs
  225. X    Murray Hill, NJ
  226. X    07974
  227. X    USA
  228. X
  229. XThe Judges believe that this is the best one line entry ever recevied.
  230. XCompile on a UN*X system, or at least using a C implementation that
  231. Xfakes it.  Very few people are able to determine what this program
  232. Xdoes by visual inspection.  I suggest that you stop reading this
  233. Xsection right now and see if you are one of the few people who can.
  234. X
  235. XSeveral points are important to understand in this program:
  236. X
  237. X    1) What is the symbol `unix' and what is its value in the program?
  238. X       Clearly `unix' is not a function, and since `unix' is not declared
  239. X       to be a data type (such as int, char, struct foo, enum, ...)
  240. X       what must `unix' be?
  241. X
  242. X    2) What is the value of the symbol "have"?  (hint: the value is
  243. X       NOT 4 characters, or 'h', or a string)  Consider the fact that:
  244. X
  245. X        char *x;
  246. X
  247. X      defines a pointer to a character (i.e. an address), and that
  248. X      the `=' assigns things is compatible types.  Since:
  249. X
  250. X            x = "have";
  251. X
  252. X      is legal C, what type of value is "have"?
  253. X
  254. X    3) Note that the following expressions yield the same value:
  255. X
  256. X        x[3]    *(x+3)      *(3+x)
  257. X
  258. X       since addition is communitive.  What can be said about the value:
  259. X
  260. X        3[x]
  261. X
  262. XDavid Korn's /bin/ksh provides us with a greatly improved version of
  263. Xthe /bin/sh.  The source for v7's /bin/sh greatly inspired this
  264. Xcontest.
  265. //E*O*F ./1987/korn.hint//
  266.  
  267. echo x - ./1987/lievaart.c
  268. sed -e 's/^X//' > "./1987/lievaart.c" << '//E*O*F ./1987/lievaart.c//'
  269. X#define D define
  270. X#D Y return
  271. X#D R for
  272. X#D e while
  273. X#D I printf
  274. X#D l int
  275. X#D C y=v+111;H(x,v)*y++= *x
  276. X#D H(a,b)R(a=b+11;a<b+89;a++)
  277. X#D s(a)t=scanf("%d",&a)
  278. Xl V[1100],u,r[]={-1,-11,-10,-9,1,11,10,9},h[]={11,18,81,88},ih[]={22,27,72,77},
  279. Xbz,lv=60,*x,*y,m,t;S(d,v,f,a,b)l*v;{l c=0,*n=v+100,bw=d<u-1?a:-9000,w,z,i,zb,q=
  280. X3-f;if(d>u){R(w=i=0;i<4;i++)w+=(m=v[h[i]])==f?300:m==q?-300:(t=v[ih[i]])==f?-50
  281. X:t==q?50:0;return w;}H(z,0){if(GZ(v,z,f,100)){c++;w= -S(d+1,n,q,-b,-bw);if(w>bw
  282. X){zb=z;bw=w;if(w>=b||w>=8003)Y w;}}}if(!c){bz=0;C;Y-S(d+1,n,q,-b,-bw);}bz=zb;Y
  283. Xd>=u-1?bw+(c<<3):bw;}main(){R(;t<1100;t+=100)R(m=0;m<100;m++)V[t+m]=m<11||m>88
  284. X||(m+1)%10<2?3:0;V[44]=V[55]=1;V[45]=V[54]=2;I("Level:");s(u);e(lv>0){do{I("Yo\
  285. Xu:");s(m);}e(!GZ(V,m,2,0)&&m!=99);if(m!=99)lv--;if(lv<15&&u<10)u+=2;I("Wait\n")
  286. X;I("Value:%d\n",S(0,V,1,-9000,9000));I("move: %d\n",(lv-=GZ(V,bz,1,0),bz));}}GZ
  287. X(v,z,f,o)l*v;{l*j,q=3-f,g=0,i,h,*k=v+z;if(*k==0)R(i=7;i>=0;i--){j=k+(h=r[i]);e(
  288. X*j==q)j+=h;if(*j==f&&j-h!=k){if(!g){g=1;C;}e(j!=k)*((j-=h)+o)=f;}}Y g;}
  289. //E*O*F ./1987/lievaart.c//
  290.  
  291. echo x - ./1987/lievaart.hint
  292. sed -e 's/^X//' > "./1987/lievaart.hint" << '//E*O*F ./1987/lievaart.hint//'
  293. XGrand Prize: <botter!rblieva> Roemer B. Lievaart
  294. X
  295. X    Roemer B. Lievaart
  296. X    VU Informatica
  297. X    Churchilllaan 173-IV
  298. X    Amsterdam, The Netherlands
  299. X
  300. XWe believe that you too will be amazed at just how much power Mr. Lievaart
  301. Xpacked into 1024 bytes!
  302. X
  303. XThis Plays the game of reversi (Othello)!  Compile and run.  It then
  304. Xasks for a playing level. Enter 0-10 (easy-hard).  It then asks for
  305. Xyour move. A move is a number within 11-88, or a 99 to pass.  Illegal
  306. Xmoves (except for an illegal pass) are rejected.  Then the computer
  307. Xdoes its move (or a 0 to pass), until the board is full.  It plays
  308. Xrather good, for such a small program!  Lievaart had to leave out the
  309. Xboard printing routine, so you'll have to take a real game board to
  310. Xplay it. ...  Also due to space-limitations (the rules for 1987 had a
  311. Xlimit of 1024 byes), Lievaart took out the passing-handler, which
  312. Xmakes its ending-game rather poor.  But further it knows all the
  313. Xrules, uses alpha-beta pruning, and it plays f.i. on mobility(!).
  314. XMost important: it can play a pretty good game of Reversi!
  315. X
  316. XThe Author was kind enough to supply the fully functional version of the
  317. Xprogram.  The file lievaart2.c contains what the program would have
  318. Xbeen without the size restriction.  This version has the full end game 
  319. Xlogic and displays the board after each move!
  320. //E*O*F ./1987/lievaart.hint//
  321.  
  322. echo x - ./1987/lievaart2.c
  323. sed -e 's/^X//' > "./1987/lievaart2.c" << '//E*O*F ./1987/lievaart2.c//'
  324. X#define D define
  325. X#D Y return
  326. X#D R for
  327. X#D e while
  328. X#D I printf
  329. X#D l int
  330. X#D W if
  331. X#D C y=v+111;H(x,v)*y++= *x
  332. X#D H(a,b)R(a=b+11;a<b+89;a++)
  333. X#D s(a)t=scanf("%d",&a)
  334. X#D U Z I
  335. X#D Z I("123\
  336. X45678\n");H(x,V){putchar(".XO"[*x]);W((x-V)%10==8){x+=2;I("%d\n",(x-V)/10-1);}}
  337. Xl V[1600],u,r[]={-1,-11,-10,-9,1,11,10,9},h[]={11,18,81,88},ih[]={22,27,72,77},
  338. Xbz,lv=60,*x,*y,m,t;S(d,v,f,_,a,b)l*v;{l c=0,*n=v+100,j=d<u-1?a:-9000,w,z,i,g,q=
  339. X3-f;W(d>u){R(w=i=0;i<4;i++)w+=(m=v[h[i]])==f?300:m==q?-300:(t=v[ih[i]])==f?-50:
  340. Xt==q?50:0;Y w;}H(z,0){W(E(v,z,f,100)){c++;w= -S(d+1,n,q,0,-b,-j);W(w>j){g=bz=z;
  341. Xj=w;W(w>=b||w>=8003)Y w;}}}W(!c){g=0;W(_){H(x,v)c+= *x==f?1:*x==3-f?-1:0;Y c>0?
  342. X8000+c:c-8000;}C;j= -S(d+1,n,q,1,-b,-j);}bz=g;Y d>=u-1?j+(c<<3):j;}main(){R(;t<
  343. X1600;t+=100)R(m=0;m<100;m++)V[t+m]=m<11||m>88||(m+1)%10<2?3:0;I("Level:");V[44]
  344. X=V[55]=1;V[45]=V[54]=2;s(u);e(lv>0){Z do{I("You:");s(m);}e(!E(V,m,2,0)&&m!=99);
  345. XW(m!=99)lv--;W(lv<15&&u<10)u+=2;U("Wait\n");I("Value:%d\n",S(0,V,1,0,-9000,9000
  346. X));I("move: %d\n",(lv-=E(V,bz,1,0),bz));}}E(v,z,f,o)l*v;{l*j,q=3-f,g=0,i,w,*k=v
  347. X+z;W(*k==0)R(i=7;i>=0;i--){j=k+(w=r[i]);e(*j==q)j+=w;W(*j==f&&j-w!=k){W(!g){g=1
  348. X;C;}e(j!=k)*((j-=w)+o)=f;}}Y g;}
  349. //E*O*F ./1987/lievaart2.c//
  350.  
  351. echo x - ./1987/rules
  352. sed -e 's/^X//' > "./1987/rules" << '//E*O*F ./1987/rules//'
  353. XWARNING: The rules and mailing address for the contest change from year
  354. X         to year.  Be sure that you consult the current set of rules
  355. X     before submitting entries.
  356. X------------------------------------------------------------------------------
  357. X
  358. XSubject: 4th International Obfuscated C Code Contest Rules
  359. XNewsgroups: comp.lang.c,comp.unix.wizards
  360. XKeywords: rules,1987,obfuscate,contest
  361. X
  362. XGOALS OF THE CONTEST:
  363. X
  364. X    * To write the most Obscure/Obfuscated C program under the rules below.
  365. X    * To show what should NOT be done in C programs.
  366. X    * To provide a safe forum for poor C code.  :-)
  367. X
  368. XRULES:
  369. X    1) The source must be 1024 characters long or less.  NO EXCEPTIONS!
  370. X
  371. X    2) To help us process your entries, we ask that you submit entries
  372. X       in the following format:   (please include the --- lines)
  373. X
  374. X---start of header items---
  375. Xname:
  376. Xorg:
  377. Xemail address:
  378. Xpostal address:
  379. Xenvironment:
  380. Xremarks:
  381. X---start of entry---
  382. XX    <place obfuscated source of 1024 characters or less here>
  383. XX    <add a leading X to each line to avoid problems with mailers>
  384. XX    <leading X's do not count toward the source character count>
  385. XX    <the first X of each source line will be removed prior to compilation>
  386. XX    <newlines count as 1 character>
  387. XX    <assume a standard 8 character tab stop>
  388. X---end of entry---
  389. X
  390. X    3) Regarding the header items:
  391. X
  392. X        * All header items except 'remark' are optional.  If you do not
  393. X          wish to answer an item, indicate so by the string:   ***NONE***
  394. X          Any text outside of the above format will be kept confidential.
  395. X
  396. X        * You can remain anonymous.   If the name item is:  ***ANONYMOUS***
  397. X          all items except the 'remarks' item will not be relased.
  398. X
  399. X        * Indicate the name of your Company or School in the 'org' item.
  400. X
  401. X        * The 'email address' item asks for a network path from a major
  402. X          site (such as amdahl) to your mailbox.
  403. X
  404. X        * If you give a 'postal address', please include your Country.
  405. X
  406. X        * Give the machine and operating system (i.e., Un*x version) on
  407. X          which your program ran.
  408. X
  409. X        * The 'remarks' item is not optional.  Please indicate:
  410. X        - how to execute or compile if something special is required
  411. X        - type of input or argument needed, if applicable
  412. X        - what this program does
  413. X        - any other remarks you wish to make
  414. X
  415. X        * If you need more than one line on a header item, place
  416. X          tab or space characters at the beginning of each additional line.
  417. X
  418. X    4) The entry should be written in a common C. (K&R + common extensions)
  419. X
  420. X    5) The program must be of original work.  All programs must be
  421. X       in the public domain.  All copyrighted programs will be rejected.
  422. X
  423. X    6) Entries must be received before 30-May-87 0:00 GMT.
  424. X       Email your entries to:
  425. X       
  426. X            ...!amdahl!obfuscate
  427. X
  428. X       Amdahl talks to hplabs, decwrl, pyramid, seismo and cbosgd.
  429. X       We will attempt to Email a confirmation of receipt of contest
  430. X       entries, however since Email is not reliable you may not receive it.
  431. X       People are encouraged to submit entries via Email, however
  432. X       one may mail entries the following postal address:
  433. X
  434. X        Landon Curt Noll
  435. X        Amdahl Corp.
  436. X        1250 E. Arques Ave.   M/S 316
  437. X        P.O. Box 3470
  438. X        Sunnyvale, CA
  439. X        94088-3470
  440. X        U.S.A.
  441. X
  442. X      Write the words: "International Obfuscated C Code Contest" near the
  443. X      bottom left corner of the envelope.
  444. X
  445. X    8) Contest entries sent in by post should indicate where TAB characters
  446. X       are to be placed, otherwise space characters will be assumed.  Each
  447. X       line will be assumed to contain a newline character.  The leading
  448. X       'X' will serve to indicate where each source line starts.
  449. X
  450. X    9) Each person may submit up to 5 entries.  Multiple entries must
  451. X       be sent in separate Email letters or postal envelopes.
  452. X
  453. X    10) People are encouraged to examine winners of the previous
  454. X        contests.  A copy of these entries was posted to mod.sources
  455. X        on or about 12-Mar-87.  Contact the mod.sources moderator
  456. X        if you missed that article.  Keep in mind that rules change from
  457. X        year to year, so some winning entries may not be valid
  458. X        entries this year.  Also what was unique and novel one
  459. X        year can get 'old' the next year.
  460. X
  461. X
  462. XANNOUNCEMENT OF WINNERS:
  463. X
  464. X    * First announcement will be at the Summer 87 Usenix BOF.
  465. X
  466. X    * An announcement will be posted to mod.announce near
  467. X      mid June 1987 stating to which newsgroup the winners
  468. X      have been posted.
  469. X
  470. X    * An article containing the winning entries will be published
  471. X      in a future issue of the "Micro/Systems Journal".
  472. X
  473. X    * Winners receive international fame and flames!  :-)
  474. X
  475. X
  476. XJUDGING:
  477. X    Awards will be given to the best entry in a number of categories.
  478. X    The actual category list will vary depending on the types of entries
  479. X    we receive.  At the moment, we are considering using the following:
  480. X
  481. X        * The best small one line program
  482. X        * The most obscure algorithm
  483. X        * The worst abuse of the C preprocessor  (note warnings below)
  484. X        * The strangest source layout
  485. X        * The most useful obfuscated program
  486. X        * <anything else so strange that it deserves an award>
  487. X
  488. X    Extra points will be given for programs which:
  489. X
  490. X        * pass lint without complaint
  491. X        * do something quasi-interesting
  492. X        * are portable
  493. X        * are unique in their obfuscation style
  494. X        * are concise
  495. X
  496. X    Points will be taken away for programs that:
  497. X
  498. X        * are very hardware or Un*x version specific
  499. X        * dump core or have compiler warnings
  500. X          (we won't take points away if you warn us in the remark item)
  501. X        * fail to compile
  502. X        * obfuscate only by overuse of #defines
  503. X          (you should do this ONLY if your use is unusual)
  504. X        * are similar to previous winners
  505. X        * are similar to previous losers  :-)
  506. X
  507. X    The Judging will be done by Landon Noll and Larry Bassel.  
  508. X    Comments & questions (not entries) about the contest can be Emailed to:
  509. X
  510. X             ...!amdahl!judges
  511. X
  512. Xchongo <Landon Curt Noll> /\cc/\
  513. XLarry Bassel
  514. //E*O*F ./1987/rules//
  515.  
  516. echo x - ./1987/wall.c
  517. sed -e 's/^X//' > "./1987/wall.c" << '//E*O*F ./1987/wall.c//'
  518. X#define iv 4 
  519. X#define v ;(void
  520. X#define XI(xi)int xi[iv*'V'];
  521. X#define L(c,l,i)c(){d(l);m(i);}
  522. X#include <stdio.h>
  523. Xint*cc,c,i,ix='\t',exit(),X='\n'*'\d';XI(VI)XI(xi)extern(*vi[])(),(*
  524. Xsignal())();char*V,cm,D['x'],M='\n',I,*gets();L(MV,V,(c+='d',ix))m(x){v)
  525. Xsignal(X/'I',vi[x]);}d(x)char*x;{v)write(i,x,i);}L(MC,V,M+I)xv(){c>=i?m(
  526. Xc/M/M+M):(d(&M),m(cm));}L(mi,V+cm,M)L(md,V,M)MM(){c=c*M%X;V-=cm;m(ix);}
  527. XLXX(){gets(D)||(vi[iv])();c=atoi(D);while(c>=X){c-=X;d("m");}V="ivxlcdm"
  528. X+iv;m(ix);}LV(){c-=c;while((i=cc[*D=getchar()])>-I)i?(c?(c<i&&l(-c-c,
  529. X"%d"),l(i,"+%d")):l(i,"(%d")):(c&&l(M,")"),l(*D,"%c")),c=i;c&&l(X,")"),l
  530. X(-i,"%c");m(iv-!(i&I));}L(ml,V,'\f')li(){m(cm+!isatty(i=I));}ii(){m(c=cm
  531. X= ++I)v)pipe(VI);cc=xi+cm++;for(V="jWYmDEnX";*V;V++)xi[*V^' ']=c,xi[*V++]
  532. X=c,c*=M,xi[*V^' ']=xi[*V]=c>>I;cc[-I]-=ix v)close(*VI);cc[M]-=M;}main(){
  533. X(*vi)();for(;v)write(VI[I],V,M));}l(xl,lx)char*lx;{v)printf(lx,xl)v)
  534. Xfflush(stdout);}L(xx,V+I,(c-=X/cm,ix))int(*vi[])()={ii,li,LXX,LV,exit,l,
  535. Xd,l,d,xv,MM,md,MC,ml,MV,xx,xx,xx,xx,MV,mi};
  536. //E*O*F ./1987/wall.c//
  537.  
  538. echo x - ./1987/wall.hint
  539. sed -e 's/^X//' > "./1987/wall.hint" << '//E*O*F ./1987/wall.hint//'
  540. XMost Useful Obfuscation: <sdcrdcf!lwall> Larry Wall
  541. X
  542. X    Larry Wall
  543. X    Unisys - System Development Group Santa Monica
  544. X    9132 Kester Ave
  545. X    Panorama City, CA  91402  USA
  546. X
  547. XTry:    lwall | bc | lwall
  548. Xinput:    x*x
  549. Xinput:    c^2
  550. X
  551. XAlso try:  lwall | bc   and   lwall | cat
  552. X
  553. XWhat we found amazing was how the flow of control was transferred
  554. Xbetween subroutines.  Careful inspection will show that the array of
  555. Xpointers to functions named `vi' refers to functions which seem to not
  556. Xbe directly called.  Even so, these pointers to functions are being
  557. Xused as an argument to signal.  Can you determine why this is being
  558. Xdone and how it is being exploted?
  559. X
  560. XSome compilers complained about this file, so we chaged: '=++I' to '= ++I'.
  561. //E*O*F ./1987/wall.hint//
  562.  
  563. echo x - ./1987/westley.c
  564. sed -e 's/^X//' > "./1987/westley.c" << '//E*O*F ./1987/westley.c//'
  565. X                char rahc
  566. X                   [ ]
  567. X                    =
  568. X                  "\n/"
  569. X                    ,
  570. X                redivider
  571. X                   [ ]
  572. X                    =
  573. X               "Able was I ere I saw elbA"
  574. X                    ,
  575. X                    *
  576. X                 deliver,reviled
  577. X                    =
  578. X                   1+1
  579. X                    ,
  580. X                   niam ; main
  581. X                   ( )
  582. X                  {/*\}
  583. X                   \*/
  584. X                 int tni
  585. X                    =
  586. X                   0x0
  587. X                    ,
  588. X                 rahctup,putchar
  589. X                   ( )
  590. X                   ,LACEDx0 = 0xDECAL,
  591. X                rof ; for
  592. X                 (;(int) (tni);)
  593. X                   (int) (tni)
  594. X              = reviled ; deliver =
  595. X                redivider
  596. X                    ;
  597. Xfor ((int)(tni)++,++reviled;reviled* *deliver;deliver++,++(int)(tni)) rof
  598. X                        =
  599. X                 (int) -1- (tni)
  600. X                  ;reviled--;--deliver;
  601. X                 (tni)  =  (int)
  602. X              - 0xDECAL + LACEDx0 -
  603. X                rof ; for
  604. X       (reviled--,(int)--(tni);(int) (tni);(int)--(tni),--deliver)
  605. X                rahctup = putchar
  606. X               (reviled* *deliver)
  607. X                    ;
  608. X                rahctup * putchar
  609. X                ((char) * (rahc))
  610. X                    ;
  611. X                   /*\
  612. X                  {\*/}
  613. //E*O*F ./1987/westley.c//
  614.  
  615. echo x - ./1987/westley.hint
  616. sed -e 's/^X//' > "./1987/westley.hint" << '//E*O*F ./1987/westley.hint//'
  617. XBest Layout: <starfire!merlyn> Brian Westley
  618. X
  619. X    Brian Westley (aka Merlyn Leroy on usenet)
  620. X    Starfire Consulting
  621. X    1121 Hamline Ave. N. #17
  622. X    St. Paul, MN
  623. X    55108
  624. X    USA
  625. X
  626. XPutchar must exist in the C library and not just as a macro.
  627. XIf it fails to compile, add the line:  #include <stdio.h>  at the
  628. Xtop of the program.
  629. X
  630. XLine by line symmetry performed better than any C beautifier.  Think
  631. Xof if it as a C Ink blot.  :-)
  632. //E*O*F ./1987/westley.hint//
  633.  
  634. echo Possible errors detected by \'wc\' [hopefully none]:
  635. temp=/tmp/shar$$
  636. trap "rm -f $temp; exit" 0 1 2 3 15
  637. cat > $temp <<\!!!
  638.      40    112    726 Makefile
  639.      16    137    827 README
  640.       1      1      3 biggar.c
  641.      32    191   1142 biggar.hint
  642.      18     33   1021 heckbert.c
  643.      14     76    430 heckbert.hint
  644.      19    130    953 hines.c
  645.      18     82    565 hines.hint
  646.       1      3     70 korn.c
  647.      45    242   1401 korn.hint
  648.      20     44   1022 lievaart.c
  649.      27    224   1303 lievaart.hint
  650.      25     61   1175 lievaart2.c
  651.     161    917   5745 rules
  652.      18     30   1021 wall.c
  653.      21    120    706 wall.hint
  654.      48     93    908 westley.c
  655.      15     73    412 westley.hint
  656.     539   2569  19430 total
  657. !!!
  658. wc  ./1987/Makefile ./1987/README ./1987/biggar.c ./1987/biggar.hint ./1987/heckbert.c ./1987/heckbert.hint ./1987/hines.c ./1987/hines.hint ./1987/korn.c ./1987/korn.hint ./1987/lievaart.c ./1987/lievaart.hint ./1987/lievaart2.c ./1987/rules ./1987/wall.
  659.  
  660. c ./1987/wall.hint ./1987/westley.c ./1987/westley.hint | sed 's=[^ ]*/==' | diff -b $temp -
  661. exit 0
  662.  
  663.