home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1025 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  55.6 KB

  1. From: chongo@hoptoad.uucp (Landon C. Noll)
  2. Newsgroups: comp.lang.c,comp.unix.wizards,alt.sources,comp.sources.d,misc.misc
  3. Subject: Reposting of the 1989 International Obfuscated C Code Contest winners
  4. Message-ID: <10825@hoptoad.uucp>
  5. Date: 16 Mar 90 20:37:36 GMT
  6.  
  7. Several people have requested a reposting of last year's IOCCC winners.
  8. They were posted late, so you may have mised them.  Sorry for the repeat.
  9.  
  10. Remember that the IOCCC contest rules changed, so one should use the
  11. 1990 rules rather than the 1989 rules below when sending in entries.
  12.  
  13. chongo <send contest entries to obfuscate@toad.com or hoptoad!obfuscate> /\cc/\
  14.  
  15. # This is a shell archive.  Remove anything before this line, then
  16. # unpack it by saving it in a file and typing "sh file".  (Files
  17. # unpacked will be owned by you and have default permissions.)
  18. #
  19. # This archive contains:
  20. #
  21. # ./1989/Makefile ./1989/README ./1989/jar.1.c ./1989/jar.1.hint
  22. # ./1989/jar.1.orig.c ./1989/jar.1.orig.sh ./1989/jar.1.sh
  23. # ./1989/jar.2.c ./1989/jar.2.hint ./1989/jay.c ./1989/jay.hint
  24. # ./1989/jay.orig.c ./1989/jay.orig.sh ./1989/jay.sh ./1989/merlyn.c
  25. # ./1989/merlyn.hint ./1989/ovdluhe.c ./1989/ovdluhe.hint
  26. # ./1989/paul.c ./1989/paul.hint ./1989/robison.c ./1989/robison.hint
  27. # ./1989/rowmer.c ./1989/rowmer.hint ./1989/rules ./1989/tromp.bsd.c
  28. # ./1989/tromp.hint ./1989/tromp.s5.c ./1989/vanb.c ./1989/vanb.hint
  29. if [ ! -d ./1989 ]
  30. then
  31.     mkdir ./1989
  32.     echo mkdir ./1989
  33. fi
  34. echo x - ./1989/Makefile
  35. sed -e 's/^X//' > ./1989/Makefile << '!FaR!OuT!'
  36. X# %W% %G% %U%
  37. X#
  38. X# 1989 makefile
  39. X
  40. XSHELL=/bin/sh
  41. XCFLAGS=-O
  42. XCC=cc
  43. X
  44. XWINNERS=ovdluhe jar.1 jar.2 jay merlyn paul robison rowmer vanb tromp 
  45. XALTERNATE=jar.1.orig jay.orig tromp.s5
  46. X
  47. Xall: ${WINNERS}
  48. X
  49. Xovdluhe: ovdluhe.c
  50. X    ${CC} ${CFLAGS} $? -o $@
  51. X
  52. X# NOTE: jar.1.c outputs its string in one section
  53. X#       this program may not print well on some terminals
  54. Xjar.1: jar.1.c jar.1.sh
  55. X    rm -f jar.1
  56. X    cp jar.1.sh jar.1
  57. X    chmod +x jar.1
  58. X# NOTE: The jar.1.orig file is the original entry
  59. Xjar.1.orig: jar.1.orig.c jar.1.orig.sh
  60. X    rm -f jar.1.orig
  61. X    cp jar.1.sh jar.1.orig
  62. X    chmod +x jar.1.orig
  63. X
  64. Xjar.2: jar.2.c
  65. X    ${CC} ${CFLAGS} $? -o $@
  66. X
  67. X# NOTE: jay.c uses the /bin/sh shell
  68. Xjay: jay.c jay.sh
  69. X    rm -f jay
  70. X    cp jay.sh jay
  71. X    chmod +x jay
  72. X# NOTE: The jay.orig.c file is the original entry
  73. Xjay.orig: jay.orig.c jay.orig.sh
  74. X    rm -f jay.orig
  75. X    cp jay.orig.sh jay.orig
  76. X    chmod +x jay.orig
  77. X
  78. Xmerlyn: merlyn.c
  79. X    ${CC} ${CFLAGS} -Dtrgpune=putchar $? -o $@
  80. X
  81. Xpaul: paul.c
  82. X    ${CC} ${CFLAGS} $? -o $@
  83. X
  84. Xrobison: robison.c
  85. X    ${CC} ${CFLAGS} $? -o $@
  86. X
  87. Xrowmer: rowmer.c
  88. X    ${CC} ${CFLAGS} $? -o $@
  89. X
  90. X# NOTE: this version requires BSD style signals and setitimer
  91. X#    this may not work well on low baud rate terminals
  92. X#    the file tromp.bsd.c is the original version
  93. Xtromp: tromp.bsd.c
  94. X    ${CC} ${CFLAGS} $? -o $@
  95. X    touch -f HI
  96. X    -chmod 0666 HI
  97. X# NOTE: sites without BSD style signals and setitimer (e.g. System V.3)
  98. X#    should use this version
  99. Xtromp.s5: tromp.s5.c
  100. X    ${CC} ${CFLAGS} $? -o $@
  101. X    touch -f HI
  102. X    -chmod 0666 HI
  103. X
  104. Xvanb: vanb.c
  105. X    ${CC} ${CFLAGS} $? -o $@
  106. X
  107. Xclean:
  108. X    rm -f ovdluhe.o jar.2.o jay.o merlyn.o paul.o robison.o
  109. X    rm -f rowmer.o tromp.o vanb.o 
  110. X    rm -f x x1 incest.c incest.o jay.orig.o tromp.bsd.o tromp.s5.o core
  111. Xclobber: clean
  112. X    rm -f ${WINNERS} 
  113. X    rm -f jar.1.o HI 
  114. X    rm -f ${ALTERNATE}
  115. Xnuke: clobber
  116. X    @true
  117. Xinstall: all
  118. X    cat ${WINNERS} > /dev/null
  119. !FaR!OuT!
  120. if [ `wc -c ./1989/Makefile | awk '{printf $1}'` -ne 1794 ]
  121. then
  122.     echo -n Size change in file ./1989/Makefile: was 1794, 'is '
  123.     wc -c ./1989/Makefile | awk '{printf $1}'
  124.     echo ''
  125. fi
  126. if [ ! -d ./1989 ]
  127. then
  128.     mkdir ./1989
  129.     echo mkdir ./1989
  130. fi
  131. echo x - ./1989/README
  132. sed -e 's/^X//' > ./1989/README << '!FaR!OuT!'
  133. X1989 marked the "The Sixth International Obfuscated C Code Contest"
  134. X
  135. XInstructions for use: Run make to compile entries (it is possible
  136. Xthat on System V or non-unix systems the makefile needs to be
  137. Xchanged). Look at the source and try to figure out what the programs
  138. Xdo, and run them with various inputs. If you want to, look at the
  139. Xhints files for (minor) spoilers.
  140. X
  141. XThis year, the Grand Prize was given to the most useful program.
  142. X
  143. XThe "Strangest abuse of the rules" award was given this year to stress
  144. Xthe fact that starting in 1990, compiling entries must result an
  145. Xexecutable regular file.
  146. X
  147. XIn two other cases, we included System V portable versions of winning
  148. Xprograms.  The makefile always uses the portable version of the "Best
  149. Xself modifying program" because there as no loss of functionality in
  150. Xusing it.  In the case of the "Best game" winner, however, some
  151. Xfunctionality is lost in the portable version and so the makefile uses
  152. Xthe original program.  System V users may need to change the makefile
  153. Xto use the s5 version.  See the hint files or the Makefile for details.
  154. X
  155. XRules and results were posted to comp.lang.c, comp.sources.unix, and
  156. Xalt.sources.  They have been made available on a wide number of Usenet
  157. Xarchive sites such as uunet.  The 1989 winners will be published in the
  158. XMicro/Systems Journal.
  159. !FaR!OuT!
  160. if [ `wc -c ./1989/README | awk '{printf $1}'` -ne 1317 ]
  161. then
  162.     echo -n Size change in file ./1989/README: was 1317, 'is '
  163.     wc -c ./1989/README | awk '{printf $1}'
  164.     echo ''
  165. fi
  166. if [ ! -d ./1989 ]
  167. then
  168.     mkdir ./1989
  169.     echo mkdir ./1989
  170. fi
  171. echo x - ./1989/jar.1.c
  172. sed -e 's/^X//' > ./1989/jar.1.c << '!FaR!OuT!'
  173. Xchar*_="Hello world.\n";
  174. !FaR!OuT!
  175. if [ `wc -c ./1989/jar.1.c | awk '{printf $1}'` -ne 25 ]
  176. then
  177.     echo -n Size change in file ./1989/jar.1.c: was 25, 'is '
  178.     wc -c ./1989/jar.1.c | awk '{printf $1}'
  179.     echo ''
  180. fi
  181. if [ ! -d ./1989 ]
  182. then
  183.     mkdir ./1989
  184.     echo mkdir ./1989
  185. fi
  186. echo x - ./1989/jar.1.hint
  187. sed -e 's/^X//' > ./1989/jar.1.hint << '!FaR!OuT!'
  188. XStrangest abuse of the rules: <...!uunet!mcvax!hutcs!jar> Jari Arkko
  189. X
  190. X    Jari Arkko
  191. X    Laboratory of Information Processing Science
  192. X    Helsinki University of Technology
  193. X    Otakaari 1
  194. X    02150 Espoo
  195. X    Finland
  196. X
  197. XJudges notes:
  198. X
  199. X    On many systems the compiler will not allow you to send the
  200. X    object file to /dev/tty.  The author suggested:
  201. X
  202. X        cc -c -o /dev/tty jar.1.c
  203. X
  204. X    On systems that have symbolic links, we suggest:
  205. X
  206. X        ln -s /dev/tty jar.1.o
  207. X        cc -c jar.1.c
  208. X    
  209. X    if your system has symbolic links.  The shell script run
  210. X    by the makefile simply cats the .o file to the terminal
  211. X    which can be used as a last resort.
  212. X
  213. X    Abuse of the rules winners usually result in a change of the
  214. X    rules.  Starting in 1990, compiling entries must result an
  215. X    regular file which can be executed.
  216. X
  217. XSelected notes from the author:
  218. X
  219. X    This program is (supposedly) the smallest C program able to
  220. X    print "Hello world.". The compilation itself produces the
  221. X    desired printout and the program need not be actually run.
  222. !FaR!OuT!
  223. if [ `wc -c ./1989/jar.1.hint | awk '{printf $1}'` -ne 973 ]
  224. then
  225.     echo -n Size change in file ./1989/jar.1.hint: was 973, 'is '
  226.     wc -c ./1989/jar.1.hint | awk '{printf $1}'
  227.     echo ''
  228. fi
  229. if [ ! -d ./1989 ]
  230. then
  231.     mkdir ./1989
  232.     echo mkdir ./1989
  233. fi
  234. echo x - ./1989/jar.1.orig.c
  235. sed -e 's/^X//' > ./1989/jar.1.orig.c << '!FaR!OuT!'
  236. Xchar*He="llo world.\n";
  237. !FaR!OuT!
  238. if [ `wc -c ./1989/jar.1.orig.c | awk '{printf $1}'` -ne 24 ]
  239. then
  240.     echo -n Size change in file ./1989/jar.1.orig.c: was 24, 'is '
  241.     wc -c ./1989/jar.1.orig.c | awk '{printf $1}'
  242.     echo ''
  243. fi
  244. if [ ! -d ./1989 ]
  245. then
  246.     mkdir ./1989
  247.     echo mkdir ./1989
  248. fi
  249. echo x - ./1989/jar.1.orig.sh
  250. sed -e 's/^X//' > ./1989/jar.1.orig.sh << '!FaR!OuT!'
  251. X:
  252. X# 'run' jar.1.orig
  253. X
  254. X# run/compile it
  255. Xrm -f jar.1.orig.o
  256. Xcc jar.1.orig.c -c
  257. Xcat jar.1.orig.o
  258. Xrm -f jar.1.orig.o
  259. !FaR!OuT!
  260. if [ `wc -c ./1989/jar.1.orig.sh | awk '{printf $1}'` -ne 113 ]
  261. then
  262.     echo -n Size change in file ./1989/jar.1.orig.sh: was 113, 'is '
  263.     wc -c ./1989/jar.1.orig.sh | awk '{printf $1}'
  264.     echo ''
  265. fi
  266. if [ ! -d ./1989 ]
  267. then
  268.     mkdir ./1989
  269.     echo mkdir ./1989
  270. fi
  271. echo x - ./1989/jar.1.sh
  272. sed -e 's/^X//' > ./1989/jar.1.sh << '!FaR!OuT!'
  273. X:
  274. X# 'run' jar.1
  275. X
  276. X# run/compile it
  277. Xrm -f jar.1.o
  278. Xcc jar.1.c -c
  279. Xcat jar.1.o
  280. Xrm -f jar.1.o
  281. !FaR!OuT!
  282. if [ `wc -c ./1989/jar.1.sh | awk '{printf $1}'` -ne 88 ]
  283. then
  284.     echo -n Size change in file ./1989/jar.1.sh: was 88, 'is '
  285.     wc -c ./1989/jar.1.sh | awk '{printf $1}'
  286.     echo ''
  287. fi
  288. if [ ! -d ./1989 ]
  289. then
  290.     mkdir ./1989
  291.     echo mkdir ./1989
  292. fi
  293. echo x - ./1989/jar.2.c
  294. sed -e 's/^X//' > ./1989/jar.2.c << '!FaR!OuT!'
  295. X#define d define
  296. X#d a include
  297. X#a <stdio.h>
  298. X#a <string.h>
  299. X#a <ctype.h>
  300. X#d p char*
  301. X#d P ,(p)
  302. X#d T(E) !strcmp(E,"()")
  303. X#d U return
  304. X#d W while
  305. X#d X sbrk(199)
  306. X#d z atof
  307. X#d e isspace
  308. X#d D A(_)
  309. X#d E S(C(_))
  310. X#d B(y) p y(_)p _;{
  311. X#d G(y,V) B(y)p i;U sprintf(i=X,"%lf",z(E)V z(S(C(D)))),i;}
  312. X
  313. X        p sbrk(),*S(),*j(),*O,*H;K,Y,M=14;double
  314. X      z();Q(_)p _;{int V=0;W(e(*_))_++;H=_;W(V|!(e
  315. X    (*H)|*H==')'||(*H=='('&&H-_)))V+=(*H=='(')-(*H==
  316. X      ')'),H++;U H-_;}B(C)U _++,Y=Q(_),_=strncpy(X,_,Y),_[
  317. X    Y]=0,_;}B(A)_++,_+=Q(_);W(e(*_))_++;U O=X,*O='(',strcpy(
  318. X  O+1,_),O;}B(Z)U _;}B(c)U C(E);}B(q)U A(E);}B(t)p i=E;U H=S(C
  319. X(D)),sprintf(O=X,T(H                 )?"(%s)":"(%s %s",i,H+1)
  320. X
  321. X         ,O;}B(F)U S(C(A(T(E)?D:_)));}L(i,s)p
  322. X
  323. Xi,*s;{U isdigit(*i)        ?         z(i)!=z(s):strcmp(i,s);}
  324. X  B(b)U L(E,S(C(D)))?"()":"t";}B(R)U E;}B(o)U z(E)<z(S(C(D)))?
  325. X    "t":"()";}G(f,+)G(g,-)G(h,*)p r[4][2]={"function"   P R,
  326. X      "quote"P C,"lambda"P Z,"defun"P j};B(j)U r[M][1]=D,*
  327. X    r[M++]=C(_);}p not[99][2]={"if"P F,"equal"P b,"<"
  328. X      P o,"+"P f,"-"P g,"*"P h,"car"P c,"cdr"P q,
  329. X        "cons"P t,"t","t"};B(S)int Li,s;p u;if(
  330. X          isdigit(*_)|T(_))U _;for(Y=M;Y--;)
  331. X        if(!strcmp(_,*r[Y]))U r[Y][1]
  332. X          ;u=E,_=D;if(*u-'(')U(*((p(*)())u)
  333. X        )(_);s=Li=M;W(!T(_))r[M][1]=E,*r[M++]
  334. X    ="",_=D;O=C(u);W(!T(O))*r[Li++]=C(O),O=A(O);U O=S
  335. X    (C(A(u))),M=s,O;}main(){H=O=X,Y=0;W(Y|!e(K=getchar()))K==
  336. X    EOF?exit(0):0,Y+=(K=='(')-(K==')'),*H++=K;*H=0,puts(S(O))
  337. X                ,
  338. X         main();{printf("XLISP 4.0\n");}}
  339. !FaR!OuT!
  340. if [ `wc -c ./1989/jar.2.c | awk '{printf $1}'` -ne 1465 ]
  341. then
  342.     echo -n Size change in file ./1989/jar.2.c: was 1465, 'is '
  343.     wc -c ./1989/jar.2.c | awk '{printf $1}'
  344.     echo ''
  345. fi
  346. if [ ! -d ./1989 ]
  347. then
  348.     mkdir ./1989
  349.     echo mkdir ./1989
  350. fi
  351. echo x - ./1989/jar.2.hint
  352. sed -e 's/^X//' > ./1989/jar.2.hint << '!FaR!OuT!'
  353. XBest of show: <...!uunet!mcvax!hutcs!jar> Jari Arkko
  354. X
  355. X    Jari Arkko
  356. X    Laboratory of Information Processing Science
  357. X    Helsinki University of Technology
  358. X    Otakaari 1
  359. X    02150 Espoo
  360. X    Finland
  361. X
  362. XJudges notes:
  363. X
  364. X    This is the most useful program entered this year. It is a
  365. X    rather large subset of lisp.  It has no error recovery, and
  366. X    performs rather poorly in a number of cases.  Even so, placing
  367. X    all this functionality in such a small, densely packed program,
  368. X    is impressive enough to win the Best of show award.
  369. X
  370. XSelected notes from the author:
  371. X
  372. X    This program implements a Lisp interpreter in 1465 bytes of source.
  373. X    Some sophisticated features supported, eg. functionals and recursion.  
  374. X    The special-forms/functions/variables implemented are:
  375. X    
  376. X        +    -    *    <    ()    
  377. X        car    cdr    cons    defun    equal
  378. X        function if    lambda    quote    t
  379. X    
  380. X    Below are sample lisp expressions you might choose to try as input.
  381. X    The program implements a conventional lisp listener, i.e. you type in
  382. X    lisp expressions (followed by CR), the program evaluates them and
  383. X    prints out the return values. End execution by typing an end-of-file
  384. X    character.
  385. X    
  386. X    (+ 2.5 3.1)
  387. X    (defun fib (n)
  388. X       (if (< n 2)
  389. X           1
  390. X           (+ (fib (- n 2)) (fib (- n 1)))))
  391. X    (fib 10)
  392. X    (defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
  393. X    (! 7)
  394. X    (defun fn1 (fn) (+ (fn 1 2) (fn 3 4)))
  395. X    (defun fn2 (a b) (+ a b))
  396. X    (fn1 (function +))
  397. X    (fn1 (function fn2))
  398. X    (fn1 (function (lambda (z1 z2) (+ z1 z2))))
  399. X    (quote a)
  400. X    (cons (quote (a b)) (quote (c d e)))
  401. X    (cons (quote (f)) ())
  402. X    (car (quote (a b c)))
  403. X    (cdr (cdr (quote (g h i))))
  404. X    
  405. X    Please do not leave any whitespace before the first parenthesis when
  406. X    you type your input, or any other unnecessary whitespace. Please try to
  407. X    avoid any undefined variables or functions, wrong number of arguments
  408. X    etc. All these errors are likely to dump core (i.e. there are no error
  409. X    checks in the program).
  410. X    
  411. X    Traditional Lisp implementations use cons cells as the main data
  412. X    structure. Lists are organized of pointer chains of these cells.
  413. X    In this program, an alternate representation was chosen: char*'s.
  414. X    All list operations, including the ones in the interpreter, are
  415. X    made using string representations of the lists. These operations
  416. X    must count parentheses and skip whitespace. This leads to extremely
  417. X    poor performance!
  418. !FaR!OuT!
  419. if [ `wc -c ./1989/jar.2.hint | awk '{printf $1}'` -ne 2274 ]
  420. then
  421.     echo -n Size change in file ./1989/jar.2.hint: was 2274, 'is '
  422.     wc -c ./1989/jar.2.hint | awk '{printf $1}'
  423.     echo ''
  424. fi
  425. if [ ! -d ./1989 ]
  426. then
  427.     mkdir ./1989
  428.     echo mkdir ./1989
  429. fi
  430. echo x - ./1989/jay.c
  431. sed -e 's/^X//' > ./1989/jay.c << '!FaR!OuT!'
  432. X
  433. X#include <stdio.h>
  434. X#define QQ      1
  435. X#define TT         1
  436. X#define cc main(c,v) int c; char **v;{char tt[12],qq[7]; int q=0,o=1,l=1,m=1;struct {int c;} f;
  437. X#define incest qq[6]='\0';tt[11]='\0';if(QQ==atoi(v[1])+1){(void)fprintf(stderr,"%s factorial = %d\n",v[1], TT);exit(1);}o=c+f
  438. X#define x ;while(EOF!=(o=getchar())){if(l && q=='Q' && o=='Q'){l=0;(void)getchar();(void)fread(qq,6,1,stdin);(void)printf("Q %6d",atoi(qq)+1);}else
  439. Xif(m && q=='T' && o=='T'){m=0;(void)fread(tt,11,1,stdin);(void)printf("T %9d\n",atoi(tt)*QQ);}else {q=o;(void)putchar(o);}}exit(0);}
  440. Xcc incest.c -o x 
  441. X#define zxc ;{/*
  442. Xcat incest.c | x $1 > x1
  443. Xif [ $? -ne 0 ]; then
  444. Xexit
  445. Xfi
  446. Xmv x1 incest.c
  447. Xchmod +x incest.c
  448. Xexec incest.c $1
  449. Xexit
  450. X*/
  451. !FaR!OuT!
  452. if [ `wc -c ./1989/jay.c | awk '{printf $1}'` -ne 711 ]
  453. then
  454.     echo -n Size change in file ./1989/jay.c: was 711, 'is '
  455.     wc -c ./1989/jay.c | awk '{printf $1}'
  456.     echo ''
  457. fi
  458. if [ ! -d ./1989 ]
  459. then
  460.     mkdir ./1989
  461.     echo mkdir ./1989
  462. fi
  463. echo x - ./1989/jay.hint
  464. sed -e 's/^X//' > ./1989/jay.hint << '!FaR!OuT!'
  465. XBest self-modifying program: <jay@mentor.cc.purdue.edu> Jay Vosburgh
  466. X
  467. X    Jay Vosburgh
  468. X    Purdue University Computing Center
  469. X    Mathematical Science Building
  470. X    West Lafayette, IN
  471. X    47907
  472. X    USA
  473. X
  474. XJudges notes:
  475. X
  476. X    Run this with a single digit argument (or wait a long time).
  477. X
  478. X    There are 2 versions of this program, the one that was entered,
  479. X    and one that was changed by the judges to be more portable. The
  480. X    makefile runs the latter version by default.
  481. X
  482. X    The shell script run by the makefile joins lines that may be
  483. X    cut up by mailers.  The file "jay.orig.c", for example, needs
  484. X    the 6th and 7th lines joined together (with a space between
  485. X    them) to recreate the original entry.  If you fix the file, you
  486. X    will need to change the last 8 linnes of "jay.orig.sh" to read:
  487. X
  488. X        cp jay.orig.c incest.c
  489. X        chmod +x incest.c
  490. X        csh incest.c $1
  491. X        rm -f incest.c x1 x
  492. X
  493. X    The more portable version, "jay.c", can be fixed by joining the
  494. X    7th and 8th lines in the same way.  As well, if you fix "jay.c"
  495. X    you will need to also change the last 8 lines to "jay.sh" to read:
  496. X
  497. X        cp jay.c incest.c
  498. X        chmod +x incest.c
  499. X        csh incest.c $1
  500. X        rm -f incest.c x1 x
  501. X
  502. XSelected notes from the author:
  503. X
  504. X    In a nutshell, this is probably the slowest and most
  505. X    obnoxious factorial program ever written.  Unfortunately, 
  506. X    the name of the C source must be "incest.c"; the name is 
  507. X    hard-coded into the program.  
  508. X
  509. X    The source is a legal shell script and a legal C program.  
  510. X    The shell script compiles itself, and then executes it, 
  511. X    giving the source as input.  The program works by successively 
  512. X    modifying #define lines each pass through.
  513. X
  514. X    Both "indent" and "cb" will damage the program, "indent" 
  515. X    much more so.
  516. !FaR!OuT!
  517. if [ `wc -c ./1989/jay.hint | awk '{printf $1}'` -ne 1664 ]
  518. then
  519.     echo -n Size change in file ./1989/jay.hint: was 1664, 'is '
  520.     wc -c ./1989/jay.hint | awk '{printf $1}'
  521.     echo ''
  522. fi
  523. if [ ! -d ./1989 ]
  524. then
  525.     mkdir ./1989
  526.     echo mkdir ./1989
  527. fi
  528. echo x - ./1989/jay.orig.c
  529. sed -e 's/^X//' > ./1989/jay.orig.c << '!FaR!OuT!'
  530. X#include <stdio.h>
  531. X#define QQ      1
  532. X#define TT         1
  533. X#define cc main(c,v) int c; char **v;{char tt[12],qq[7]; int q=0,o=1,l=1,m=1;struct {int c;} f;
  534. X#define incest qq[6]='\0';tt[11]='\0';if(QQ==atoi(v[1])+1){(void)fprintf(stderr,"%s factorial = %d\n",v[1], TT);exit(1);}o=c+f
  535. X#define x ;while(EOF!=(o=getchar())){if(l && q=='Q' && o=='Q'){l=0;(void)getchar();(void)fread(qq,6,1,stdin);(void)printf("Q %6d",atoi(qq)+1);}else
  536. Xif(m && q=='T' && o=='T'){m=0;(void)fread(tt,11,1,stdin);(void)printf("T %9d\n",atoi(tt)*QQ);}else {q=o;(void)putchar(o);}}exit(0);}
  537. Xcc incest.c -o x 
  538. X#define zxc ;{/*
  539. Xcat incest.c | x $1 >! x1
  540. Xif ($status != 0) then 
  541. Xexit
  542. Xendif
  543. Xmv x1 incest.c
  544. Xchmod +x incest.c
  545. Xexec incest.c $1
  546. Xexit
  547. X*/
  548. !FaR!OuT!
  549. if [ `wc -c ./1989/jay.orig.c | awk '{printf $1}'` -ne 716 ]
  550. then
  551.     echo -n Size change in file ./1989/jay.orig.c: was 716, 'is '
  552.     wc -c ./1989/jay.orig.c | awk '{printf $1}'
  553.     echo ''
  554. fi
  555. if [ ! -d ./1989 ]
  556. then
  557.     mkdir ./1989
  558.     echo mkdir ./1989
  559. fi
  560. echo x - ./1989/jay.orig.sh
  561. sed -e 's/^X//' > ./1989/jay.orig.sh << '!FaR!OuT!'
  562. X:
  563. X# to run jay in the 'proper' way
  564. X
  565. X# parse args
  566. Xif [ $# -ne 1 ]; then
  567. X    echo "usage: $0 number" 1>&2
  568. X    exit 1
  569. Xfi
  570. X
  571. X# run/compile it
  572. Xrm -f incest.c x1 x
  573. Xex - <<EOF
  574. Xr jay.orig.c
  575. X6,7j
  576. Xw incest.c
  577. XEOF
  578. Xchmod +x incest.c
  579. Xcsh incest.c $1
  580. Xrm -f incest.c x1 x
  581. !FaR!OuT!
  582. if [ `wc -c ./1989/jay.orig.sh | awk '{printf $1}'` -ne 254 ]
  583. then
  584.     echo -n Size change in file ./1989/jay.orig.sh: was 254, 'is '
  585.     wc -c ./1989/jay.orig.sh | awk '{printf $1}'
  586.     echo ''
  587. fi
  588. if [ ! -d ./1989 ]
  589. then
  590.     mkdir ./1989
  591.     echo mkdir ./1989
  592. fi
  593. echo x - ./1989/jay.sh
  594. sed -e 's/^X//' > ./1989/jay.sh << '!FaR!OuT!'
  595. X:
  596. X# to run jay in the 'proper' way
  597. X
  598. X# parse args
  599. Xif [ $# -ne 1 ]; then
  600. X    echo "usage: $0 number" 1>&2
  601. X    exit 1
  602. Xfi
  603. X
  604. X# run/compile it
  605. Xrm -f incest.c x1 x
  606. Xex - <<EOF
  607. Xr jay.c
  608. X7,8j
  609. Xw incest.c
  610. XEOF
  611. Xchmod +x incest.c
  612. Xincest.c $1
  613. Xrm -f incest.c x1 x
  614. !FaR!OuT!
  615. if [ `wc -c ./1989/jay.sh | awk '{printf $1}'` -ne 245 ]
  616. then
  617.     echo -n Size change in file ./1989/jay.sh: was 245, 'is '
  618.     wc -c ./1989/jay.sh | awk '{printf $1}'
  619.     echo ''
  620. fi
  621. if [ ! -d ./1989 ]
  622. then
  623.     mkdir ./1989
  624.     echo mkdir ./1989
  625. fi
  626. echo x - ./1989/merlyn.c
  627. sed -e 's/^X//' > ./1989/merlyn.c << '!FaR!OuT!'
  628. X
  629. X/**//*/};)/**/main(/*//**/tang       ,gnat/**//*/,ABBA~,0-0(avnz;)0-0,tang,raeN
  630. X,ABBA(niam&&)))2-]--tang-[kri      - =raeN(&&0<)/*clerk*/,noon,raeN){(!tang&&
  631. Xnoon!=-1&&(gnat&2)&&((raeN&&(    getchar(noon+0)))||(1-raeN&&(trgpune(noon
  632. X)))))||tang&&znva(/*//**/tang   ,tang,tang/**|**//*/((||)))0(enupgrt=raeN
  633. X(&&tang!(||)))0(rahcteg=raeN(  &&1==tang((&&1-^)gnat=raeN(;;;)tang,gnat
  634. X,ABBA,0(avnz;)gnat:46+]552&)191+gnat([kri?0>]652%)191+gnat([kri=gnat
  635. X(&&)1-^gnat(&&)1& ABBA(!;)raeN,tang,gnat,ABBA(avnz&&0>ABBA{)raeN
  636. X,/**/);}znva(/*//**/tang,gnat,ABBA/**//*/(niam;}1-,78-,611-,321
  637. X-,321-,001-,64-,43-,801-,001-,301-,321-,511-,53-,54,44,34,24
  638. X,14,04,93,83,73,63,53,43,33,85,75,65,55,45,35,25,15,05,94,84
  639. X,74,64,0,0,0,0,0,0,/**/){ABBA='N'==65;(ABBA&&(gnat=trgpune
  640. X(0)))||(!ABBA&&(gnat=getchar(0-0)));(--tang&1)&&(gnat='n'<=
  641. Xgnat&&gnat<='z'||'a'<=gnat&&gnat<='m'||'N'<=gnat&&gnat<='Z'
  642. X||'A'<=gnat&&gnat<='M'?(((gnat&/*//**/31/**//*/,21,11,01,9,8
  643. X,7,6,5,4,3,2,1,62,52,42,/**/)+12)%26)+(gnat&/*//**/32/**//*/,
  644. X22,12,02,91,81,71,61,51,41{=]652[kri};)/*pry*/)+65:gnat);main
  645. X(/*//**\**/tang^tang/**//*/,/*       */,~/*//*-*/tang,gnat,ABBA-
  646. X0/**//*/(niam&&ABBA||))))tang(       rahcteg&&1-1=<enrA(||))tang(
  647. Xenupgrt&&1==enrA((&&)2&gnat(&&         )1-^tang(&&ABBA!(;)85- =tang
  648. X(&&)'a\'=gnat(&&)1-==gnat(&&)4          ==ABBA(&&tang!;))))0(enupgrt=
  649. X gnat(&&)tang!((||)))0(rahcteg        =gnat(&&tang((&&ABBA;;)1-'A'=!
  650. X'Z'=tang(&&ABBA{)enrA/***/);gnat    ^-1&&znva(tang+1,gnat,1+gnat); 
  651. X main(ABBA&2/*//*\\**/,tang,gnat    ,ABBA/**//*/(avnz/**/);}/*//**/
  652. !FaR!OuT!
  653. if [ `wc -c ./1989/merlyn.c | awk '{printf $1}'` -ne 1517 ]
  654. then
  655.     echo -n Size change in file ./1989/merlyn.c: was 1517, 'is '
  656.     wc -c ./1989/merlyn.c | awk '{printf $1}'
  657.     echo ''
  658. fi
  659. if [ ! -d ./1989 ]
  660. then
  661.     mkdir ./1989
  662.     echo mkdir ./1989
  663. fi
  664. echo x - ./1989/merlyn.hint
  665. sed -e 's/^X//' > ./1989/merlyn.hint << '!FaR!OuT!'
  666. XMost algorithms in one program: <merlyn@starfire> Merlyn LeRoy (Brian Westley)
  667. X
  668. X    Merlyn LeRoy (Brian Westley)
  669. X    Starfire Consulting
  670. X    1026 Blair Ave.
  671. X    St. Pault, MN  
  672. X    55104  
  673. X    USA
  674. X
  675. XJudges notes:
  676. X
  677. X    There is a secret way to get ONE of the versions to print out
  678. X    "Hello, world!\n".  Can you find how to do it?
  679. X
  680. X    Try the following commands:
  681. X
  682. X        merlyn < merlyn.c > ver0.c
  683. X        merlyn 1 < merlyn.c > ver1.c
  684. X        merlyn 1 2 < merlyn.c > ver2.c
  685. X        merlyn 1 2 3 < merlyn.c > ver3.c
  686. X    
  687. X    Try compiling and running the 4 resulting programs.
  688. X
  689. XSelected notes from the author:
  690. X
  691. X    This is a filter.  If it is run with no arguments, it copies
  692. X    stdin to stdout.  With one argument, it ROT13's stdin to
  693. X    stdout.  With two arguments, it reverses stdin to stdout.  With
  694. X    three arguments, it does both.  It requires the ASCII character
  695. X    set, with all characters being in 0..255, and EOF must be -1.
  696. X    Also requires two's complement (I think).
  697. X
  698. X    The source code will run if ROT13'ed and/or reversed, using a
  699. X    different algorithm for each version (hereafter referred to as
  700. X    ver0 (original), ver1 (ROT13), ver2 (reversed), and ver3 
  701. X    (ROT13 and reversed)).
  702. X
  703. X    When compiling these versions, one needs to define 'trgpune'
  704. X    in the compile line.  Example:
  705. X
  706. X        cc -Dtrgpune=putchar ver3.c -o ver3
  707. X
  708. X    "trgpune" is the ROT13 of getchar(), so getchar() and putchar()
  709. X    are exchanged in the ROT13 counterpart.  It is easy to see that
  710. X    this is unavoidable.  I must have a #define for a library
  711. X    function; otherwise I would have an unidentifed extern for the
  712. X    ROT13 version.  If I then define this function, it won't link
  713. X    in the library version for the ORIGINAL code, since my
  714. X    definition will supercede the library function.  Hence, the
  715. X    compiler option gives me putchar(), and allows me to use
  716. X    getchar().  I pass a dummy argument to getchar() to eliminate
  717. X    "variable number of args" from lint (unless it checks against
  718. X    the library).  Otherwise, all versions lint reasonably (main
  719. X    returns random value & constant in conditional context [when I
  720. X    check for ROT13 version] is all it complains about).
  721. X
  722. X    ver0 and ver1 use a range check and a calculation to do ROT13,
  723. X    while ver2 and ver3 use table lookup.  All versions contain
  724. X    main() and it's ROT13 fn, znva().  ver0/ver1 [ver2/ver3] are
  725. X    (of course) syntactically identical, since the syntax is in the
  726. X    non-alphabetic characters.  However, since one program starts
  727. X    at main() while it's ROT13 counterpart starts at znva(), znva()
  728. X    calls main (znva() is also used for output).
  729. X
  730. X    All versions use recursion to work.  If the program is NOT
  731. X    reversing it's output, it prints out the (possibly ROT13'd)
  732. X    character before recursing, otherwise it prints it out
  733. X    afterward (or doesn't recurse at all when EOF is reached).
  734. X    Since most of this code is identical, it is put into znva() and
  735. X    called with a first parameter of 0 as a flag (as "main()", it's
  736. X    first argument (argc) must be at least one).
  737. X
  738. X    I can't use any flow control.  If I used if(), I would have a
  739. X    function vs() to define in the ROT13 version.  But a function
  740. X    called vs() turns into a function called if() in the original,
  741. X    so it can't be done.  Therefore, I do:
  742. X
  743. X        expr1 && expr2 && (expr3=etc);
  744. X
  745. X    which is the same as:
  746. X
  747. X         if (expr1 && expr2) expr3=etc;
  748. X
  749. X    A/UX on the Macintosh doesn't get this right; it evaluates ALL
  750. X    expressions if they aren't in an assignment or conditional
  751. X    statement.  This might warrant a warning, since other compilers
  752. X    may do this.  I found MANY compilers botched:
  753. X
  754. X        expr1 && (expr2,expr3);
  755. X
  756. X    expr2 was OFTEN evaluated even if expr1 was false.  I removed
  757. X    such statements to make it more portable.
  758. X
  759. X    The variable names are worth noting:
  760. X
  761. X         'irk' and  'vex' are ROT13 pairs and are synonyms.
  762. X        'Near' and 'Arne' are ROT13 pairs and are anagrams.
  763. X        'NOON' and 'ABBA' are ROT13 pairs and are palindromes.
  764. X        'tang' and 'gnat' are both ROT13 and palindrome pairs!
  765. X
  766. X    Normally (!), a reversible C program is done thus:
  767. X
  768. X        /**/ forward code /*/ edoc drawkcab /**/
  769. X
  770. X    If your compiler nests comments, it will get this wrong.
  771. X    However, I have made some bits of the code palindromic,
  772. X    (or different, but reversible) so it is more like:
  773. X
  774. X        /**/forward/*//**/ palindromic /**//*/drawkcab/**/
  775. X
  776. X    The code can therefore be interlaced.  There are eight
  777. X    such palindromic bits.  You can find them within the
  778. X    /*//**/   /**//*/ pairs.
  779. X
  780. X    The body of the code of ver0 and ver1 is a large lumpy 'K' (for
  781. X    Kernighan); the code of ver2 and ver3 is a flat-topped and
  782. X    lumpier 'R' (for Ritchie).  Judicious use of spaces and tabs
  783. X    helped here.  It barely fits on an 80x24 screen.  Squint.  Note
  784. X    that the code must start with a blank line, or the reversed version
  785. X    will lack a terminating newline.
  786. !FaR!OuT!
  787. if [ `wc -c ./1989/merlyn.hint | awk '{printf $1}'` -ne 4663 ]
  788. then
  789.     echo -n Size change in file ./1989/merlyn.hint: was 4663, 'is '
  790.     wc -c ./1989/merlyn.hint | awk '{printf $1}'
  791.     echo ''
  792. fi
  793. if [ ! -d ./1989 ]
  794. then
  795.     mkdir ./1989
  796.     echo mkdir ./1989
  797. fi
  798. echo x - ./1989/ovdluhe.c
  799. sed -e 's/^X//' > ./1989/ovdluhe.c << '!FaR!OuT!'
  800. X#include <string.h>
  801. Xtypedef char ape
  802. X#define D define
  803. X#D EA register
  804. X#D EP unsigned
  805. X#D A 1
  806. X#D AP (A<<A)
  807. X#D P (A<<AP)
  808. X#D AE ((P<<P)<<A)
  809. X#D PE (((A<<P)<<P)<<P)
  810. X#D E ((EP)A>>A)
  811. X#D APE {EA EP ape ea=AE;while(ea--) e[ea]=E;}
  812. X;ape a[PE+A],ap,*ae,p[P+A],e[AE];
  813. Xmain(){ape pe,*ep=a;srand((EP)time((long)E));
  814. Xwhile(((*(ep++)=getchar())!=-A)&&((ep-a)<PE));
  815. X*(ae= --ep)=E;for(ap=E;ap<=P;){APE;if(pe=PA())
  816. X{putchar(pe);if(ap<P){p[ap]=pe;ap++;}else{
  817. Xep=p+A;while(*ep) *(ep-A)= *(ep++); *(ep-A)=pe;}}else break;}}
  818. XPA(){EA ape pe,*ep=a,pa,Ap=E;for(ep=a;ep<ae-P;ep++)
  819. Xif(!strncmp(ep,p,ap)){e[*(ep+ap)]++;Ap++;}if(!Ap)return(Ap);
  820. Xpa=rand()%Ap+A;pe=~E,Ap=!Ap;while((Ap+=e[++pe])<pa);return(pe);}
  821. !FaR!OuT!
  822. if [ `wc -c ./1989/ovdluhe.c | awk '{printf $1}'` -ne 678 ]
  823. then
  824.     echo -n Size change in file ./1989/ovdluhe.c: was 678, 'is '
  825.     wc -c ./1989/ovdluhe.c | awk '{printf $1}'
  826.     echo ''
  827. fi
  828. if [ ! -d ./1989 ]
  829. then
  830.     mkdir ./1989
  831.     echo mkdir ./1989
  832. fi
  833. echo x - ./1989/ovdluhe.hint
  834. sed -e 's/^X//' > ./1989/ovdluhe.hint << '!FaR!OuT!'
  835. XMost humorous output: <...!unido!cernvax!ethz!ovdluhe> Oskar von der Luehe
  836. X
  837. X    Oskar von der Luehe
  838. X    Institut fuer Astronomie
  839. X    ETH - Zentrum
  840. X    8092 Zuerich
  841. X    Switzerland
  842. X
  843. XJudges notes:
  844. X
  845. X    Run this program using your favorite text file as input.  Files
  846. X    such as mailboxes, man pages and usenet articles are especially
  847. X    recommended.  You will get different output each time you run it.
  848. X
  849. X    Run the program this way:
  850. X
  851. X        ovdluhe < textfile
  852. X
  853. X    The program stops when it reaches the end of the template buffer 
  854. X    by chance or is killed.
  855. X
  856. XSelected notes from the author:
  857. X
  858. X    This program implements an "Eddington ape" - it generates
  859. X    random text from a supplied template.  The template text file
  860. X    is read through stdin.  The larger the template, the better the
  861. X    result.  A maximum of 2**12 chars are used. From the template,
  862. X    the program calculates the statistics of chars that immediately
  863. X    follow a given string (correlator string) of a certain length
  864. X    (currently 4 - can be varied by changing the definition for P
  865. X    accordingly).  A character is randomly chosen, weighted by its
  866. X    probability to occur after the correlator string.  That
  867. X    character is printed to stdout and placed at the end of the
  868. X    correlator string, whose first character is discarded.
  869. X    Meaningful words are therefore usually preserved, the effect on
  870. X    sentences can be dramatically random.
  871. X
  872. X    You might want to vary the definition of P between 2 and 10 and
  873. X    observe the result.
  874. !FaR!OuT!
  875. if [ `wc -c ./1989/ovdluhe.hint | awk '{printf $1}'` -ne 1426 ]
  876. then
  877.     echo -n Size change in file ./1989/ovdluhe.hint: was 1426, 'is '
  878.     wc -c ./1989/ovdluhe.hint | awk '{printf $1}'
  879.     echo ''
  880. fi
  881. if [ ! -d ./1989 ]
  882. then
  883.     mkdir ./1989
  884.     echo mkdir ./1989
  885. fi
  886. echo x - ./1989/paul.c
  887. sed -e 's/^X//' > ./1989/paul.c << '!FaR!OuT!'
  888. X#include <stdio.h>
  889. X#define f int
  890. X#define v (void)printf(
  891. X#define x ),exit(1);
  892. X#define y ){if(n)c=z(n,u),u=n,n=c;o[i]=n?'0'+(1&*n):'0';}
  893. X#define z(a,b) (f*)(~1&*a^(f)b)
  894. X#define k(l) if(!(l=(f*)malloc(sizeof(l))))v 23+m x if(1&(f)l)v 39+m x*l=
  895. Xr(p,q,d)f*p,*q;{char o[81];f*n=p,i=39,*c,*u=d?q:z(p,q);o[40]='0'+(1&*p);
  896. Xfor(;i>=0;i--y u=d?z(p,q):q;n=p;for(i=41;i<79;i++y o[i++]='\r';o[i++]=0;
  897. Xv o);(void)fflush(stdout);sleep(1);}
  898. Xmain(a,c)char**c;{char*u,*malloc(),*m=
  899. X"Usage: black [string]\n\0No more memory\n\0Unusable memory alignment\n\0jt,s@m@ (beleY%XX&Yz {z&z}i|R(|)*((.)i)hiniFiGJ%FG.JJgJ: ;;&;z {z&z}-RS/ROiOV OP+PsaPh+ijainnjmamfmfAlnnnnphppopv%vvgv.aABiB1/BVP11/1.%..&.OhrR-WV V1#1VP1CcC0R\
  900. X\n\n'CVP0\n!\n\n'\nEaEEnEamat!akckk'kwaww'wz,zzozEit +",
  901. X*n=m;f*q,*p=0,*g,b=3,d;
  902. Xif(a>2)v m x n=a>1?c[1]:n;
  903. X/*v"\t\t\t\t\tV\n");*/
  904. Xk(q)0;u=n;a=~1&'j';
  905. Xwhile(a!='x'){
  906. X    /*r(q,p,b);*/
  907. X    for(;;u+=3){
  908. X        u= *u?u:n;
  909. X        if((~1&*u)==a&&(1&*q)<<1==(2&u[2]))break;
  910. X    }
  911. X    a=~1&u[1];
  912. X    d=(8&u[2])>>3;
  913. X    if(16&u[2])putchar(u[3]);
  914. X    if(4&u[2])*q|=1;else*q&=~1;
  915. X    if(b==d)g=p;else{
  916. X        g=z(q,p);
  917. X        if(!g){k(g)(f)q;*q^=(f)g;}
  918. X    }
  919. X    p=q;q=g;b=1-d;
  920. X}
  921. X/*r(q,p,b);v"\n");*/exit(0);
  922. X}
  923. !FaR!OuT!
  924. if [ `wc -c ./1989/paul.c | awk '{printf $1}'` -ne 1149 ]
  925. then
  926.     echo -n Size change in file ./1989/paul.c: was 1149, 'is '
  927.     wc -c ./1989/paul.c | awk '{printf $1}'
  928.     echo ''
  929. fi
  930. if [ ! -d ./1989 ]
  931. then
  932.     mkdir ./1989
  933.     echo mkdir ./1989
  934. fi
  935. echo x - ./1989/paul.hint
  936. sed -e 's/^X//' > ./1989/paul.hint << '!FaR!OuT!'
  937. XMost complex algorithm: <...!oliveb!cirrusl!paul> Paul E. Black
  938. X
  939. X    Paul E. Black
  940. X    CIRRUS LOGIC, Inc.
  941. X    1463 Centre Pointe Dr.
  942. X    Milpitas, CA 
  943. X    95035 
  944. X    USA
  945. X
  946. XJudges notes:
  947. X
  948. X    The original source contained a long line which caused many
  949. X    mailers to barf.  The original file may be re-constructed by
  950. X    removeing the trailing "\" on line 12 and joining lines 12 and
  951. X    13 together without a space.
  952. X
  953. X    WHAT FOLLOWS IS A DETAILED PROGRAM EXPLINATION AND SPOILER.
  954. X    IF YOU WANT A REAL CHALLENGE, DON'T READ ANY FURTHER AND TRY
  955. X    TO UNDERSTAND THE PROGRAM VIA THE SOURCE.
  956. X
  957. X
  958. XSelected notes from the author:
  959. X
  960. X    This programs computes and prints Fibonacci numbers by
  961. X    simulating a Turing machine with the proper program.
  962. X    Understanding the C program, i.e., a Turing machine simulator,
  963. X    is only the first and simplest step.  The Turing machine
  964. X    program must be understood, too!  (it is trivial, perhaps even
  965. X    natural to write incredibly obscure Turing programs.)
  966. X
  967. X    If the program is invoked with an operand, the operand is used
  968. X    as the Turing program.  It includes a "trace" facility,
  969. X    subroutine r (commented out for obscurity), to help write and
  970. X    debug Turing programs.  Just the thing for some fun in a Theory
  971. X    of Computation class.
  972. X
  973. X    The Turing machine tape is represented as a doubly linked list
  974. X    of pointers.  The forward and backward links are XOR'd together
  975. X    and stored in one pointer.  If we always keep one of the links
  976. X    on hand, we can recover the other link at any time.  The
  977. X    variable q is the scan head (and a pointer at some tape cell),
  978. X    and p is a "previous" link.  The state of the tape is stored in
  979. X    the low order bit of the pointer.  Since we always allocate an
  980. X    even number of bytes, the low order bit carries no information
  981. X    (see portability below.) Memory representing a tape cell is
  982. X    allocated when the cell is first scanned.  Thus the simulation
  983. X    begins with a tape effectively the size of virtual memory set
  984. X    to all zeros.  Since a header can be added to any Turing
  985. X    program to write initial data and position the scan head, this
  986. X    is little loss of generality.
  987. X
  988. X    The simulated Turing machine has a single tape with either an 1
  989. X    or a 0 in each cell.  The Turing machine language format is a
  990. X    string of three bytes.  The first byte is the current state.
  991. X    The second byte is the next state.  (The last bit of states is
  992. X    ignored, e.g., B and C are the same state, in an attempt to be
  993. X    able to have interesting words in the program.)  The third byte
  994. X    is composed of bits.  Bit 1 (2&byte) is the symbol scanned,
  995. X    i.e. an instruction is selected for state and for a match with
  996. X    the symbol under the scan head.  Bit 2 (4&byte) is the new
  997. X    symbol to be written to the cell.  Bit 3 (8&byte) is the
  998. X    direction to move the scan head: 0 for left and 1 for right.
  999. X    If bit 4 (16&byte) is true, the next character is sent to
  1000. X    stdout.  (I added this feature so programs could print
  1001. X    results.)
  1002. X
  1003. X    The Turing machine has next state 'j' when it begins.  The
  1004. X    cycle is 1) exit if the state is 'x', 2) find the next
  1005. X    instruction (given the state and the character under the scan
  1006. X    head).  [The program string is searched forward for the next
  1007. X    matching instruction.  If the end of the string is reached, the
  1008. X    search begins again at the first of the string.  Thus states
  1009. X    can be used as local labels in different places.]  3) change to
  1010. X    the next state, 4) print a character if indicated, 5) write the
  1011. X    tape symbol, and 6) move the scan head.  The cycle then repeats
  1012. X    with step 1.  A call to the trace routine is just before step
  1013. X    2, but is commented out.
  1014. X
  1015. X    The following ROT13'ed text is a quick outline of the actual
  1016. X    Turing program:
  1017. X
  1018. X        Urer vf n dhvpx bhgyvar bs gur Ghevat cebtenz: gur
  1019. X        cerivbhf naq pheerag Svobanppv ahzoref ner xrcg va onfr
  1020. X        1 sbez jvgu gur pheerag ba gur evtug.  Gur svefg guerr
  1021. X        fgrcf frg hc gur svefg gjb ahzoref, 1 naq 1.  Gura
  1022. X        [ortvaavat jvgu "@ ("] n znexre bs VVV vf perngrq naq
  1023. X        gur pheerag ahzore vf pbcvrq gb gur evtug bs gur
  1024. X        znexre.  Gura [ortvaavat jvgu "BI "] gur ahzore vf
  1025. X        pbairegrq gb ovanel ol ercrngrq qvivqvat ol 2 yrnivat V
  1026. X        sbe erznvaqre 1, naq VV sbe erznvaqre 0.  Arkg
  1027. X        [ortvaavat jvgu "JI "] gur ovanel ercerfragngvba vf
  1028. X        cevagrq naq vgf flzobyf naq gur znexre ner renfrq.
  1029. X        Svanyyl [ortvaavat jvgu "RRa"] gur gjb ahzoref ner
  1030. X        nqqrq naq gur pheerag ahzore pbcvrq gb gur yrsg gb
  1031. X        orpbzr gur cerivbhf.  Gura gur plpyr ercrngf.
  1032. X
  1033. X    The program requires that the lowest bit of a pointer to be 0.
  1034. X
  1035. X    I could have squeezed the program under 1024 bytes without the
  1036. X    trace subroutine, but I felt it was important for understanding
  1037. X    the program.  Besides it is fun to watch the tape zooming back
  1038. X    and forth as the program runs.  A much better debugger or trace
  1039. X    could easily be added.
  1040. !FaR!OuT!
  1041. if [ `wc -c ./1989/paul.hint | awk '{printf $1}'` -ne 4708 ]
  1042. then
  1043.     echo -n Size change in file ./1989/paul.hint: was 4708, 'is '
  1044.     wc -c ./1989/paul.hint | awk '{printf $1}'
  1045.     echo ''
  1046. fi
  1047. if [ ! -d ./1989 ]
  1048. then
  1049.     mkdir ./1989
  1050.     echo mkdir ./1989
  1051. fi
  1052. echo x - ./1989/robison.c
  1053. sed -e 's/^X//' > ./1989/robison.c << '!FaR!OuT!'
  1054. X typedef struct A*B,*(*C)();struct A{C(*d)();B e;}*v(),*b;C n[256];
  1055. X# include <stdio.h>
  1056. X#define a (d->e)
  1057. X#define o (B)printf
  1058. X#define X(_){return _;}
  1059. X#define Y(_,A)B _(d,e)B d,e;X(A)
  1060. X#define Z(P)C P(f,g,h,i)C f,g,h,i;X(P)
  1061. X#define c(_)(b=(B)malloc(sizeof(*b)),b->d=_,b->e=d,b)
  1062. X#define _(D,E,F,G,H)B D();Y(D/**/f,E)Y(D/**/g,F)Y(D/**/h,G)Y(D/**/i,H)Y(D,(*(*d->d)(D/**/f,D/**/g,D/**/h,D/**/i))(d,e))
  1063. XZ(f)
  1064. XZ(g)
  1065. XZ(h)
  1066. XZ(i)
  1067. X_(j,d,d,j a,j a)
  1068. X_(k,d,c(h),c(h),c(h))
  1069. X_(l,c(i),d,c(i),c(i))
  1070. X_(m,c(g),c(f),l(m a),k(m a))
  1071. X_(p,d,l(m(d)),k(p a),l(m a))
  1072. X_(q,l(p(d)),m(d),l a,k(q a))
  1073. X_(r,m(d),k(mf a),l(r a),k a)
  1074. X_(s,d,e,o("0",s a),o("1",s a))
  1075. X_(t,d,p(e),k(t(a,e)),v(k(t(a,e)),e))
  1076. X_(u,k(e),l(r(e)),k(v(a,e)),l(v(a,e)))
  1077. X_(v,e,r(e),u(e,a),u(q(e),a))
  1078. X_(w,o("0"),d,s(d),s(d))
  1079. X_(x,(*n[getchar()])(d),o("-1"),w(p(d,o("-"))),xh(d))
  1080. X_(y,xf(mg()),v(d,p(yf())),v(d,yf()),t(d,yf()))
  1081. X_(z,xf(yf()),(*(*j(d)->d)(w,x))(d),xf(k(d)),xf(l(d)))
  1082. Xmain(){
  1083. Xn['(']=zf;n['x']=yi;n['-']=yg;
  1084. Xn['+']=yh;n['0']=zh;n['1']=zi;
  1085. Xn[' ']=xf;n[')']=n['\n']=kf;
  1086. Xo("\n",zg(yf()));}
  1087. !FaR!OuT!
  1088. if [ `wc -c ./1989/robison.c | awk '{printf $1}'` -ne 1023 ]
  1089. then
  1090.     echo -n Size change in file ./1989/robison.c: was 1023, 'is '
  1091.     wc -c ./1989/robison.c | awk '{printf $1}'
  1092.     echo ''
  1093. fi
  1094. if [ ! -d ./1989 ]
  1095. then
  1096.     mkdir ./1989
  1097.     echo mkdir ./1989
  1098. fi
  1099. echo x - ./1989/robison.hint
  1100. sed -e 's/^X//' > ./1989/robison.hint << '!FaR!OuT!'
  1101. XBest minimal use of C: <robison@a.cs.uiuc.edu> Arch D. Robison
  1102. X
  1103. X    Arch D. Robison
  1104. X    University of Illinois
  1105. X    1304 W. Springfield Ave.
  1106. X    Urbana, IL 
  1107. X    61801
  1108. X    USA
  1109. X
  1110. XJudges notes:
  1111. X
  1112. X    Sites with punch card facilities will be happy to note that
  1113. X    the source deck can be re-collated with an ASCII sort.
  1114. X
  1115. X    Note that this program uses only a small subset of the
  1116. X    constructs that the C language supports.
  1117. X
  1118. XSelected notes from the author:
  1119. X
  1120. X    This program is a handy picoAPL interpreter written in C--.  It
  1121. X    outputs the evaluation of an APL expression from standard
  1122. X    input.  Functions are limited to dyadic +,-,x, and unary -;
  1123. X    numerals must be binary.  Parentheses may be used for
  1124. X    grouping.  For example:
  1125. X
  1126. X        101x111-100
  1127. X
  1128. X    prints:
  1129. X
  1130. X        1111
  1131. X
  1132. X    That is 5x(7-4) is 15.  (APL groups from right to left.)
  1133. X    Extending it to the full APL language should be trivial.
  1134. X
  1135. X    The C-- language improves the C language by removing superfluous
  1136. X    and confusing features: arithmetic, logical operations, shifts,
  1137. X    relationals, address-of, and flow control.  In fact, the only 
  1138. X    expressions retained are function calls, indirection, array 
  1139. X    assignments, the ',' operator, and sizeof.  Despite these
  1140. X    restrictions, the C-- program does arithmetic on arbitrarily 
  1141. X    large binary numbers.
  1142. X
  1143. X    To obtain a C-- reference, simply rip out the irrelevant pages 
  1144. X    from your K&R C manual.  To obtain a C-- compiler, simply rip
  1145. X    out the irrelevant bytes from your cc compiler.
  1146. !FaR!OuT!
  1147. if [ `wc -c ./1989/robison.hint | awk '{printf $1}'` -ne 1418 ]
  1148. then
  1149.     echo -n Size change in file ./1989/robison.hint: was 1418, 'is '
  1150.     wc -c ./1989/robison.hint | awk '{printf $1}'
  1151.     echo ''
  1152. fi
  1153. if [ ! -d ./1989 ]
  1154. then
  1155.     mkdir ./1989
  1156.     echo mkdir ./1989
  1157. fi
  1158. echo x - ./1989/rowmer.c
  1159. sed -e 's/^X//' > ./1989/rowmer.c << '!FaR!OuT!'
  1160. X
  1161. X
  1162. X                                    char
  1163. X                                _3141592654[3141
  1164. X      ],__3141[3141];_314159[31415],_3141[31415];main(){register char*
  1165. X      _3_141,*_3_1415, *_3__1415; register int _314,_31415,__31415,*_31,
  1166. X    _3_14159,__3_1415;*_3141592654=__31415=2,_3141592654[0][_3141592654
  1167. X   -1]=1[__3141]=5;__3_1415=1;do{_3_14159=_314=0,__31415++;for( _31415
  1168. X  =0;_31415<(3,14-4)*__31415;_31415++)_31415[_3141]=_314159[_31415]= -
  1169. X1;_3141[*_314159=_3_14159]=_314;_3_141=_3141592654+__3_1415;_3_1415=
  1170. X__3_1415    +__3141;for            (_31415 = 3141-
  1171. X       __3_1415  ;            _31415;_31415--
  1172. X       ,_3_141 ++,            _3_1415++){_314
  1173. X       +=_314<<2 ;            _314<<=1;_314+=
  1174. X      *_3_1415;_31             =_314159+_314;
  1175. X      if(!(*_31+1)             )* _31 =_314 /
  1176. X      __31415,_314             [_3141]=_314 %
  1177. X      __31415 ;* (             _3__1415=_3_141
  1178. X     )+= *_3_1415              = *_31;while(*
  1179. X     _3__1415 >=              31415/3141 ) *
  1180. X     _3__1415+= -              10,(*--_3__1415
  1181. X    )++;_314=_314              [_3141]; if ( !
  1182. X    _3_14159 && *              _3_1415)_3_14159
  1183. X    =1,__3_1415 =              3141-_31415;}if(
  1184. X    _314+(__31415               >>1)>=__31415 )
  1185. X    while ( ++ *               _3_141==3141/314
  1186. X       )*_3_141--=0               ;}while(_3_14159
  1187. X       ) ; { char *               __3_14= "3.1415";
  1188. X       write((3,1),               (--*__3_14,__3_14
  1189. X       ),(_3_14159                ++,++_3_14159))+
  1190. X      3.1415926; }                for ( _31415 = 1;
  1191. X     _31415<3141-                1;_31415++)write(
  1192. X    31415% 314-(                3,14),_3141592654[
  1193. X  _31415    ] +                   "0123456789","314"
  1194. X  [ 3]+1)-_314;                   puts((*_3141592654=0
  1195. X,_3141592654))                    ;_314= *"3.141592";}
  1196. !FaR!OuT!
  1197. if [ `wc -c ./1989/rowmer.c | awk '{printf $1}'` -ne 1454 ]
  1198. then
  1199.     echo -n Size change in file ./1989/rowmer.c: was 1454, 'is '
  1200.     wc -c ./1989/rowmer.c | awk '{printf $1}'
  1201.     echo ''
  1202. fi
  1203. if [ ! -d ./1989 ]
  1204. then
  1205.     mkdir ./1989
  1206.     echo mkdir ./1989
  1207. fi
  1208. echo x - ./1989/rowmer.hint
  1209. sed -e 's/^X//' > ./1989/rowmer.hint << '!FaR!OuT!'
  1210. XBest layout: <roemer@cs.vu.nl> Roemer B. Lievaart
  1211. X
  1212. X    Lievaart, Roemer B.
  1213. X    VU-Informatica, Amsterdam
  1214. X    Marcusstraat 29/2, 
  1215. X    NL 1091 TJ Amsterdam
  1216. X    Netherlands
  1217. X
  1218. XJudges notes:
  1219. X
  1220. X    Do you know what this program does?  If you do, look again,
  1221. X    there is more here than meets the PI.
  1222. X
  1223. XSelected notes from the author:
  1224. X
  1225. X    Passes lint, but not with the strictest options, for it
  1226. X    contains some "null-statements", as well two identifiers
  1227. X    which are, if compilers only take 6 characters, the same.  It
  1228. X    also uses write(2), so not totally system independent.
  1229. X
  1230. X    You are very much invited to pass this program through a
  1231. X    C-beautifier. (First strip newlines and tabs, if your cb can't
  1232. X    do that.)
  1233. !FaR!OuT!
  1234. if [ `wc -c ./1989/rowmer.hint | awk '{printf $1}'` -ne 673 ]
  1235. then
  1236.     echo -n Size change in file ./1989/rowmer.hint: was 673, 'is '
  1237.     wc -c ./1989/rowmer.hint | awk '{printf $1}'
  1238.     echo ''
  1239. fi
  1240. if [ ! -d ./1989 ]
  1241. then
  1242.     mkdir ./1989
  1243.     echo mkdir ./1989
  1244. fi
  1245. echo x - ./1989/rules
  1246. sed -e 's/^X//' > ./1989/rules << '!FaR!OuT!'
  1247. XSubject: 6th International Obfuscated C Code Contest Rules
  1248. XNewsgroups: comp.lang.c,comp.unix.wizards
  1249. XKeywords: rules,1989,obfuscate,contest,IOCCC
  1250. X
  1251. X    Obfuscate:  tr.v.  -cated, -cating, -cates.  1. a.  To render obscure.
  1252. X        b.  To darken.  2. To confuse:  his emotions obfuscated his
  1253. X        judgement.  [LLat. obfuscare, to darken : ob(intensive) +
  1254. X        Lat. fuscare, to darken < fuscus, dark.] -obfuscation n.
  1255. X        obfuscatory adj.
  1256. X
  1257. XGOALS OF THE CONTEST:
  1258. X
  1259. X    * To write the most Obscure/Obfuscated C program under the rules below.
  1260. X    * To show what should NOT be done in C programs.
  1261. X    * To provide a safe forum for poor C code.  :-)
  1262. X
  1263. XRULES:
  1264. X
  1265. X    To help us handle the vast volume of entries, we ask that you
  1266. X    follow the rules below.  Sorry for the length, but we need all
  1267. X    the help we can get!
  1268. X
  1269. X    1) Your source MUST be 1536 bytes or less, and it must be a complete
  1270. X       program, not just a subroutine.
  1271. X
  1272. X    2) To help us process your entries, we ask that you submit entries
  1273. X       in the following format.  Please be sure to include the --- lines,
  1274. X       otherwise our extraction program may skip your entry!
  1275. X
  1276. X---header items---
  1277. Xname:        Your name, of course!
  1278. Xorg:        School/Company/Organization
  1279. Xemail address:    Email address from a well known site, or in a registered domain
  1280. Xpostal address:    Postal address
  1281. X        include your country as well
  1282. Xenvironment:    Indicate the Hardware 
  1283. X        and OS under which your program was tested
  1284. Xentry:        5    <number of entries sent so far including this one>
  1285. Xremarks:        <see below>
  1286. X---how to compile---
  1287. XX Give the command(s) needed to compile your program.
  1288. XX Follow the same rules as given for the program below except that the
  1289. XX command size must be 160 characters or less.
  1290. X---program---
  1291. XX Place obfuscated source of 1536 characters or less in this section.
  1292. XX Add a leading X to each line to avoid problems with mailers.
  1293. XX Some mailers don't like files with very long lines.  If your entry contains E
  1294. XC    lines longer 80 chars we ask you to form continuation line sets.  To form E
  1295. XC    a continuation line set, place an 'E' character at the point of a split E
  1296. XC    and place a C (instead of an X) at the beginning of the next line. E
  1297. XC    Finally, end the continuation line set as normal.
  1298. XX The E\nC's and leading X's will be removed prior to extraction and thus E
  1299. XC    they don't contribute toward the source character count.  All other E
  1300. XC    characters are considered to be source.  Whitespace after 'X' or 'C' E
  1301. XC    and before the 'E' is significant, we added it here for readability.
  1302. XX Newlines and tabs each count as 1 character.  Assume 8 character tab stops.
  1303. XX If your entry does not end in a newline, leave a final 'E' on the end. E
  1304. X---end---
  1305. X
  1306. X    3) Regarding the header items:
  1307. X
  1308. X        * Any text outside of the above format will be kept confidential.
  1309. X
  1310. X        * All header lines are required, but you may use 'anonymous'
  1311. X          for any header line other than 'remarks' or 'entry'.
  1312. X
  1313. X        * In the 'remarks' please include:
  1314. X        - what this program does
  1315. X        - why you think the program is obfuscated
  1316. X        - any other remarks you wish to make
  1317. X
  1318. X    4) Your entry should be written in common C. (K&R + common extensions)
  1319. X       Due to the lack of ANSI C compilers, it is suggested, but not
  1320. X       required, that you avoid use of constructs unique to ANSI C.
  1321. X
  1322. X    5) The program must be of original work.  All programs must be
  1323. X       in the public domain.  All copyrighted programs will be rejected.
  1324. X
  1325. X    6) Entries must be received between 26-Mar-89 0:00 GMT and 
  1326. X       26-May-89 0:00 GMT.  Email your entries to:
  1327. X       
  1328. X        ...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!obfuscate
  1329. X
  1330. X       We will attempt to Email a confirmation of receipt of contest
  1331. X       entries, however since Email is not reliable you may not receive it.
  1332. X       We regret that we can no longer accept entries via postal mail.
  1333. X
  1334. X    7) Each person may submit up to 8 entries.  Multiple entries must
  1335. X       be sent in separate Email letters.
  1336. X    
  1337. X    8) Entries that can not be built automatically in a portable makefile 
  1338. X       are not allowed.  (e.g., don't use #include "/dev/tty")
  1339. X
  1340. X
  1341. XANNOUNCEMENT OF WINNERS:
  1342. X
  1343. X    * First announcement will be at the Summer 89 Usenix BOF.
  1344. X
  1345. X    * Winning entries will be posted in mid June 1989 to 
  1346. X      comp.sources.unix as well as news groups where these rules 
  1347. X      were posted.  (depending on the judges work load)
  1348. X    
  1349. X    * Winning entries will be deposited into the uunet archives.
  1350. X
  1351. X    * An article containing the winning entries will be published
  1352. X      in a future issue of the "Micro/Systems Journal".
  1353. X
  1354. X    * Winners receive international fame and flames!  :-)
  1355. X
  1356. X
  1357. XJUDGING:
  1358. X
  1359. X    Awards will be given to the best entry in a number of categories.
  1360. X    The actual category list will vary depending on the types of entries
  1361. X    we receive.  As a guide, consider using the following:
  1362. X
  1363. X        * The best small one line program
  1364. X        * The most obscure algorithm
  1365. X        * The strangest source layout
  1366. X        * The most useful obfuscated program
  1367. X        * The most creatively obfuscated program
  1368. X        * Best obfuscated entry smaller than 256 bytes
  1369. X        * Best obfuscated entry smaller than 1024 bytes
  1370. X        * <anything else so strange that it deserves an award>
  1371. X
  1372. XPOINTS TO PONDER:
  1373. X
  1374. X    People are encouraged to examine winners of the previous
  1375. X    contests.  A copy of these entries was posted to
  1376. X    comp.sources.unix.  Contact the comp.sources.unix moderator, or
  1377. X    some archive site (such as uunet).  Keep in mind that rules
  1378. X    change from year to year, so some winning entries may not be
  1379. X    valid entries this year.  What was unique and novel one year
  1380. X    might be 'old' the next year.  In short, use your best judgement.
  1381. X
  1382. X    We examine each entry on several levels of confusion.  For example
  1383. X    each entry is judged when we:
  1384. X
  1385. X        * look at the original source
  1386. X        * run it through:  sed -e ',^#[     ]*define,d' | /lib/cpp
  1387. X        * run it through a C beautifier
  1388. X        * examine the algorithm
  1389. X        * compile and lint it
  1390. X        * execute it
  1391. X    
  1392. X    One line programs are best when they are short, obscure and concise.
  1393. X
  1394. X    We tend to dislike programs that:
  1395. X
  1396. X        * are very hardware specific
  1397. X        * are very OS or Un*x version specific
  1398. X             (index/strchr differences are ok, but 
  1399. X              socket/streams specific code is likely not to be)
  1400. X        * dump core or have compiler warnings
  1401. X             (it is ok only if you warn us in the 'remark' header item)
  1402. X        * won't compile under both BSD or SYS V Un*x
  1403. X        * use an excessively long compile line to get around the
  1404. X             size limit
  1405. X        * are longer than they need to be
  1406. X        * are similar to previous winners
  1407. X        * are similar to previous losers  :-)
  1408. X
  1409. X    Simply abusing #defines or -Dfoo=bar won't go as far as a program
  1410. X    that is more well rounded in confusion.
  1411. X
  1412. X    Unless you are cramped for space, or unless you are entering the 
  1413. X    'best one liner' category, we suggest that you format your program 
  1414. X    in a more creative way than simply forming excessively long lines.
  1415. X
  1416. X    We like programs that:
  1417. X
  1418. X        * are as concise and small as they need to be
  1419. X        * do something quasi-interesting
  1420. X        * pass lint without complaint
  1421. X        * are portable
  1422. X        * are unique or novel in their obfuscation style
  1423. X        * use a number of different types of obfuscation
  1424. X        * make us laugh and/or throw up  :-)
  1425. X
  1426. X    Some types of programs can't excel in some areas.  We try to account
  1427. X    for this by giving awards to programs in a number of areas.  Of course,
  1428. X    your program doesn't have to excel in all areas, but doing well in
  1429. X    several helps.
  1430. X
  1431. X    Be creative!
  1432. X
  1433. X    The Judging will be done by Landon Noll and Larry Bassel.  If you have
  1434. X    any QUESTIONS or COMMENTS, please feel free to send them to:
  1435. X
  1436. X        ...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!judges
  1437. X        judges@toad.com
  1438. X
  1439. X    however contest entries should be sent to: 
  1440. X    
  1441. X        ...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!obfuscate
  1442. X        obfuscate@toad.com
  1443. X
  1444. X
  1445. Xchongo <Landon Curt Noll> /\cc/\      hoptoad!chongo
  1446. XLarry Bassel                  {amdahl,ucbvax,cbosgd}|sun!lab
  1447. X
  1448. Xp.s. The 1989 contest is being dedicated to the                 |\_.^
  1449. X     brain that was removed from Bill the Cat.                 (@ o)
  1450. X                               *Ackpt!*   {:} 
  1451. X                                       U
  1452. !FaR!OuT!
  1453. if [ `wc -c ./1989/rules | awk '{printf $1}'` -ne 7848 ]
  1454. then
  1455.     echo -n Size change in file ./1989/rules: was 7848, 'is '
  1456.     wc -c ./1989/rules | awk '{printf $1}'
  1457.     echo ''
  1458. fi
  1459. if [ ! -d ./1989 ]
  1460. then
  1461.     mkdir ./1989
  1462.     echo mkdir ./1989
  1463. fi
  1464. echo x - ./1989/tromp.bsd.c
  1465. sed -e 's/^X//' > ./1989/tromp.bsd.c << '!FaR!OuT!'
  1466. Xlong h[4];t(){h[3]-=h[3]/3000;setitimer(0,h,0);}c,d,l,v[]={(int)t,0,2},w,s,I,K
  1467. X=0,i=276,j,k,q[276],Q[276],*n=q,*m,x=17,f[]={7,-13,-12,1,8,-11,-12,-1,9,-1,1,
  1468. X12,3,-13,-12,-1,12,-1,11,1,15,-1,13,1,18,-1,1,2,0,-12,-1,11,1,-12,1,13,10,-12,
  1469. X1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-11,-12,
  1470. X12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i])-Q[i]
  1471. X){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);printf(
  1472. X"\033[%dm  "+(K-k?0:5),k);K=k;}Q[263]=c=getchar();}G(b){for(i=4;i--;)if(q[i?b+
  1473. Xn[i]:b])return 0;return 1;}g(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char*
  1474. X*V,*a;{h[3]=1000000/(l=C>1?atoi(V[1]):2);for(a=C>2?V[2]:"jkl pq";i;i--)*n++=i<
  1475. X25||i%12<2?7:0;srand(getpid());system("stty cbreak -echo stop u");sigvec(14,v,
  1476. X0);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<0){if(G(x+
  1477. X12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(j%12==10){
  1478. Xfor(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G(x=17)||(c
  1479. X=a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if(c==a[2])G
  1480. X(++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){s=sigblock(
  1481. X8192);printf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]=
  1482. X0);while(getchar()-a[4]);puts("\033[H\033[J\033[7m");sigsetmask(s);}}d=popen(
  1483. X"stty -cbreak echo stop \023;cat - HI|sort -rn|head -20>/tmp/$$;mv /tmp/$$ HI\
  1484. X;cat HI","w");fprintf(d,"%4d on level %1d by %s\n",w,l,getlogin());pclose(d);}
  1485. !FaR!OuT!
  1486. if [ `wc -c ./1989/tromp.bsd.c | awk '{printf $1}'` -ne 1494 ]
  1487. then
  1488.     echo -n Size change in file ./1989/tromp.bsd.c: was 1494, 'is '
  1489.     wc -c ./1989/tromp.bsd.c | awk '{printf $1}'
  1490.     echo ''
  1491. fi
  1492. if [ ! -d ./1989 ]
  1493. then
  1494.     mkdir ./1989
  1495.     echo mkdir ./1989
  1496. fi
  1497. echo x - ./1989/tromp.hint
  1498. sed -e 's/^X//' > ./1989/tromp.hint << '!FaR!OuT!'
  1499. XBest game: <tromp@piring.cwi.nl> John Tromp
  1500. X
  1501. X    John Tromp
  1502. X    Centre for Mathematics and Computer Science (CWI)
  1503. X    Oetgensstraat 7
  1504. X    1701CK Heerhugowaard
  1505. X    Netherlands
  1506. X
  1507. XJudges notes:
  1508. X
  1509. X    This is a character terminal version of the TETRIS program. 
  1510. X    It runs on a VT100 compatible terminal or emulator.  It is 
  1511. X    best used at 4800 baud or more.
  1512. X    
  1513. X    Usage:
  1514. X
  1515. X        tromp [drops_per_sec  [cmd_string]]
  1516. X    
  1517. X    By default, "drops_per_sec", the number of times an object
  1518. X    will drop in a second, is 2.  The default "cmd_string" is
  1519. X    "jkl pq".  The first 6 characters of "cmd_string" relate
  1520. X    to the following 6 game commands:
  1521. X
  1522. X        j - left
  1523. X        k - rotate
  1524. X        l - right
  1525. X      <space> - drop
  1526. X        p - pause
  1527. X        q - quit
  1528. X    
  1529. X    Specifying "cmd_string" allows one to re-define the commands.
  1530. X    The pause command pauses the game, clears the screen and
  1531. X    prints the current score.  To un-pause, type the pause
  1532. X    character again, which by default is "p".
  1533. X
  1534. X    This original program requires a BSD-style interval timer and
  1535. X    and new BSD signal interface.  If you are using System V.3
  1536. X    or earlier, for example, you will need to make "tromp.s5" 
  1537. X    instead of "tromp".  You can change the default make rule 
  1538. X    by changing "tromp" to "tromp.s5" in the "WINNERS=..." line
  1539. X    of the Makefile.
  1540. X
  1541. X    The "tromp.s5" version is not as functional as "tromp".  
  1542. X    The "drops_per_sec" is ignored and defaults to 1.  The level 
  1543. X    is always reported as 0.
  1544. X
  1545. X    As was stated last year, we are likely to be more strict about
  1546. X    portability in the future.  [ We mean it this time :-) ]
  1547. X
  1548. XSelected notes from the author:
  1549. X
  1550. X    This program plays the familiar game of `TETRIS' with the
  1551. X    following features:
  1552. X
  1553. X        * outputs vt100-like escape-sequences for cursor 
  1554. X          positioning and normal/reverse video in curses 
  1555. X          like fashion (minimal output for screen updates)
  1556. X
  1557. X        * continuously increasing speed (except in pause)
  1558. X
  1559. X        * start speed selectable by giving n as first argument, 
  1560. X          where n is the number of drops per second (default=2).
  1561. X
  1562. X        * controls also selectable by giving as the second argument 
  1563. X          a string of 6 characters.  By default they are "jkl pq".
  1564. X
  1565. X        * screen is blanked during the pause and the score is shown
  1566. X
  1567. X        * maintains a high-score table
  1568. X
  1569. X    Giving a full path name for the table will result in a
  1570. X    system-wide hiscore allowing a competition between users.
  1571. !FaR!OuT!
  1572. if [ `wc -c ./1989/tromp.hint | awk '{printf $1}'` -ne 2302 ]
  1573. then
  1574.     echo -n Size change in file ./1989/tromp.hint: was 2302, 'is '
  1575.     wc -c ./1989/tromp.hint | awk '{printf $1}'
  1576.     echo ''
  1577. fi
  1578. if [ ! -d ./1989 ]
  1579. then
  1580.     mkdir ./1989
  1581.     echo mkdir ./1989
  1582. fi
  1583. echo x - ./1989/tromp.s5.c
  1584. sed -e 's/^X//' > ./1989/tromp.s5.c << '!FaR!OuT!'
  1585. Xlong h[4];E[80],S;t(){signal(14,t);if(S)longjmp(E,1);}c,d,l,v[]={(int)t,0,2},
  1586. Xw,s,I,K=0,i=276,j,k,q[276],Q[276],*n=q,*m,x=17,f[]={7,-13,-12,1,8,-11,-12,-1,9
  1587. X,-1,1,12,3,-13,-12,-1,12,-1,11,1,15,-1,13,1,18,-1,1,2,0,-12,-1,11,1,-12,1,13,
  1588. X10,-12,1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-
  1589. X11,-12,12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i
  1590. X])-Q[i]){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);
  1591. Xprintf("\033[%dm  "+(K-k?0:5),k);K=k;}alarm(1);Q[263]=c=((S=1)&&!setjmp(E))?
  1592. Xgetchar():-1;alarm(0);}G(b){for(i=4;i--;)if(q[i?b+n[i]:b])return 0;return 1;}g
  1593. X(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char**V,*a;{for(a=C>2?V[2]:
  1594. X"jkl pq";i;i--)*n++=i<25||i%12<2?7:0;srand(getpid());system("stty raw -echo");
  1595. Xsignal(14,t);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<
  1596. X0){if(G(x+12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(
  1597. Xj%12==10){for(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G
  1598. X(x=17)||(c=a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if
  1599. X(c==a[2])G(++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){
  1600. Xprintf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]=0);
  1601. Xwhile(getchar()-a[4]);puts("\033[H\033[J\033[7m");}}system("stty cooked echo")
  1602. X;d=popen("cat - HI|sort -rn|sed -n 1,20p>/tmp/$$;mv /tmp/$$ HI;cat HI","w");
  1603. Xfprintf(d,"%4d on level %1d by %s\n",w,l,getlogin());pclose(d);}
  1604. !FaR!OuT!
  1605. if [ `wc -c ./1989/tromp.s5.c | awk '{printf $1}'` -ne 1466 ]
  1606. then
  1607.     echo -n Size change in file ./1989/tromp.s5.c: was 1466, 'is '
  1608.     wc -c ./1989/tromp.s5.c | awk '{printf $1}'
  1609.     echo ''
  1610. fi
  1611. if [ ! -d ./1989 ]
  1612. then
  1613.     mkdir ./1989
  1614.     echo mkdir ./1989
  1615. fi
  1616. echo x - ./1989/vanb.c
  1617. sed -e 's/^X//' > ./1989/vanb.c << '!FaR!OuT!'
  1618. Xmain(Q,O)char**O;{if(--Q){main(Q,O);O[Q][0]^=0X80;for(O[0][0]=0;O[++O[0][0]]!=0;)if(O[O[0][0]][0]>0)puts(O[O[0][0]]);puts("----------");main(Q,O);}}
  1619. !FaR!OuT!
  1620. if [ `wc -c ./1989/vanb.c | awk '{printf $1}'` -ne 149 ]
  1621. then
  1622.     echo -n Size change in file ./1989/vanb.c: was 149, 'is '
  1623.     wc -c ./1989/vanb.c | awk '{printf $1}'
  1624.     echo ''
  1625. fi
  1626. if [ ! -d ./1989 ]
  1627. then
  1628.     mkdir ./1989
  1629.     echo mkdir ./1989
  1630. fi
  1631. echo x - ./1989/vanb.hint
  1632. sed -e 's/^X//' > ./1989/vanb.hint << '!FaR!OuT!'
  1633. XBest one liner: <...!{decvax|akgua}!ucf-cs!vanb> David Van Brackle
  1634. X
  1635. X    David Van Brackle
  1636. X    Department of Computer Science
  1637. X    University of Central Florida
  1638. X    Orlando, Florida 
  1639. X    32816
  1640. X    USA 
  1641. X
  1642. XJudges notes:
  1643. X
  1644. X    This program computes all proper subsets of the set of
  1645. X    arguments passed to it.  Each subset is printed with one 
  1646. X    element on each line, followed by a line of ten dashes.
  1647. X
  1648. X    Try:
  1649. X
  1650. X        vanb unix is better than os/2
  1651. X
  1652. XSelected notes from the author:
  1653. X
  1654. X    The program has the following charming and possibly 
  1655. X    non-portable features:
  1656. X
  1657. X        * It has no local or global variables, 
  1658. X          only the command-line parameters.
  1659. X
  1660. X        * It calls main recursively.
  1661. X
  1662. X            * It alters the command-line parameters.  (gives Turbo-C fits)
  1663. X
  1664. X            * It uses the fact that if the high bit is set in a character
  1665. X              variable, the value is negative.
  1666. !FaR!OuT!
  1667. if [ `wc -c ./1989/vanb.hint | awk '{printf $1}'` -ne 842 ]
  1668. then
  1669.     echo -n Size change in file ./1989/vanb.hint: was 842, 'is '
  1670.     wc -c ./1989/vanb.hint | awk '{printf $1}'
  1671.     echo ''
  1672. fi
  1673. exit
  1674.