home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume32 / iocc1992 / part05 < prev    next >
Encoding:
Text File  |  1992-09-10  |  13.2 KB  |  493 lines

  1. Newsgroups: comp.sources.misc
  2. From: chongo@toad.com (Landon Curt Noll)
  3. Subject:  v32i032:  ioccc.1992 - 1992 International Obfuscated C Code Contest winners, Part05/05
  4. Message-ID: <1992Sep10.154628.27454@sparky.imd.sterling.com>
  5. X-Md4-Signature: 7ab4a9cf9e687398a2d8b7b9578270d5
  6. Date: Thu, 10 Sep 1992 15:46:28 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: chongo@toad.com (Landon Curt Noll)
  10. Posting-number: Volume 32, Issue 32
  11. Archive-name: ioccc.1992/part05
  12. Environment: C
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  1992/adrian.grep.1 1992/adrian.grep.2 1992/adrian.grep.3
  19. #   1992/adrian.grep.4 1992/adrian.grep.5 1992/adrian.grep.from
  20. #   1992/adrian.grep.try 1992/ant.hint 1992/buzzard.2.README
  21. #   1992/buzzard.2.c 1992/demo1.th 1992/demo2.th 1992/demo3.th
  22. #   1992/demo4.th 1992/demo5.th 1992/demo6.th 1992/westley.c
  23. # Wrapped by kent@sparky on Thu Sep 10 10:21:22 1992
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 5 (of 5)."'
  27. if test -f '1992/adrian.grep.1' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'1992/adrian.grep.1'\"
  29. else
  30.   echo shar: Extracting \"'1992/adrian.grep.1'\" \(131 characters\)
  31.   sed "s/^X//" >'1992/adrian.grep.1' <<'END_OF_FILE'
  32. X    <q0> a <q1>          The first state to appear is the start state
  33. X    <q1> b <q2>
  34. X    <q2> c [q3]
  35. X    [q3]                    
  36. END_OF_FILE
  37.   if test 131 -ne `wc -c <'1992/adrian.grep.1'`; then
  38.     echo shar: \"'1992/adrian.grep.1'\" unpacked with wrong size!
  39.   fi
  40.   # end of '1992/adrian.grep.1'
  41. fi
  42. if test -f '1992/adrian.grep.2' -a "${1}" != "-c" ; then 
  43.   echo shar: Will not clobber existing file \"'1992/adrian.grep.2'\"
  44. else
  45.   echo shar: Extracting \"'1992/adrian.grep.2'\" \(64 characters\)
  46.   sed "s/^X//" >'1992/adrian.grep.2' <<'END_OF_FILE'
  47. X    <q0> a <q1>
  48. X    <q1> b <q2>
  49. X    <q2> c [q3]
  50. X    [q3] . [q3]
  51. END_OF_FILE
  52.   if test 64 -ne `wc -c <'1992/adrian.grep.2'`; then
  53.     echo shar: \"'1992/adrian.grep.2'\" unpacked with wrong size!
  54.   fi
  55.   # end of '1992/adrian.grep.2'
  56. fi
  57. if test -f '1992/adrian.grep.3' -a "${1}" != "-c" ; then 
  58.   echo shar: Will not clobber existing file \"'1992/adrian.grep.3'\"
  59. else
  60.   echo shar: Extracting \"'1992/adrian.grep.3'\" \(99 characters\)
  61.   sed "s/^X//" >'1992/adrian.grep.3' <<'END_OF_FILE'
  62. X    <q0> a <q1> . <q0>
  63. X    <q1> b <q2> a <q1> . <q0>
  64. X    <q2> c [q3] a <q1> . <q0>
  65. X    [q3] . <q1>
  66. END_OF_FILE
  67.   if test 99 -ne `wc -c <'1992/adrian.grep.3'`; then
  68.     echo shar: \"'1992/adrian.grep.3'\" unpacked with wrong size!
  69.   fi
  70.   # end of '1992/adrian.grep.3'
  71. fi
  72. if test -f '1992/adrian.grep.4' -a "${1}" != "-c" ; then 
  73.   echo shar: Will not clobber existing file \"'1992/adrian.grep.4'\"
  74. else
  75.   echo shar: Extracting \"'1992/adrian.grep.4'\" \(48 characters\)
  76.   sed "s/^X//" >'1992/adrian.grep.4' <<'END_OF_FILE'
  77. X    [q0] a <q1>
  78. X    <q1> b <q2>
  79. X    <q2> c [q0]
  80. END_OF_FILE
  81.   if test 48 -ne `wc -c <'1992/adrian.grep.4'`; then
  82.     echo shar: \"'1992/adrian.grep.4'\" unpacked with wrong size!
  83.   fi
  84.   # end of '1992/adrian.grep.4'
  85. fi
  86. if test -f '1992/adrian.grep.5' -a "${1}" != "-c" ; then 
  87.   echo shar: Will not clobber existing file \"'1992/adrian.grep.5'\"
  88. else
  89.   echo shar: Extracting \"'1992/adrian.grep.5'\" \(60 characters\)
  90.   sed "s/^X//" >'1992/adrian.grep.5' <<'END_OF_FILE'
  91. X    <q0> ab <q1>
  92. X    <q1> cd <q2>
  93. X    <q2> ef [q3]
  94. X    [q3]
  95. END_OF_FILE
  96.   if test 60 -ne `wc -c <'1992/adrian.grep.5'`; then
  97.     echo shar: \"'1992/adrian.grep.5'\" unpacked with wrong size!
  98.   fi
  99.   # end of '1992/adrian.grep.5'
  100. fi
  101. if test -f '1992/adrian.grep.from' -a "${1}" != "-c" ; then 
  102.   echo shar: Will not clobber existing file \"'1992/adrian.grep.from'\"
  103. else
  104.   echo shar: Extracting \"'1992/adrian.grep.from'\" \(92 characters\)
  105.   sed "s/^X//" >'1992/adrian.grep.from' <<'END_OF_FILE'
  106. X<q0> F <q1>
  107. X<q1> r <q2>
  108. X<q2> o <q3>
  109. X<q3> m <q4>
  110. X<q4> : <q5> . [q6]
  111. X<q5> . <q5>
  112. X[q6] . [q6]
  113. X
  114. END_OF_FILE
  115.   if test 92 -ne `wc -c <'1992/adrian.grep.from'`; then
  116.     echo shar: \"'1992/adrian.grep.from'\" unpacked with wrong size!
  117.   fi
  118.   # end of '1992/adrian.grep.from'
  119. fi
  120. if test -f '1992/adrian.grep.try' -a "${1}" != "-c" ; then 
  121.   echo shar: Will not clobber existing file \"'1992/adrian.grep.try'\"
  122. else
  123.   echo shar: Extracting \"'1992/adrian.grep.try'\" \(101 characters\)
  124.   sed "s/^X//" >'1992/adrian.grep.try' <<'END_OF_FILE'
  125. X    <q0> t <q1> . <q0>
  126. X    <q1> hc <q2> t <q1> . <q0>
  127. X    <q2> eh [q3] t <q1> . <q0>
  128. X    [q3] . <q1>
  129. END_OF_FILE
  130.   if test 101 -ne `wc -c <'1992/adrian.grep.try'`; then
  131.     echo shar: \"'1992/adrian.grep.try'\" unpacked with wrong size!
  132.   fi
  133.   # end of '1992/adrian.grep.try'
  134. fi
  135. if test -f '1992/ant.hint' -a "${1}" != "-c" ; then 
  136.   echo shar: Will not clobber existing file \"'1992/ant.hint'\"
  137. else
  138.   echo shar: Extracting \"'1992/ant.hint'\" \(656 characters\)
  139.   sed "s/^X//" >'1992/ant.hint' <<'END_OF_FILE'
  140. XBest Utility: <ant@mks.com> Anthony C Howe
  141. X
  142. X    Anthony C Howe
  143. X    Mortice Kern Systems Inc.
  144. X    Unit 1, 14 Weber Street North
  145. X    Waterloo, Ontario
  146. X    N2J 3G4
  147. X    Canada
  148. X
  149. X
  150. XJudges' comments:
  151. X
  152. X   To use:
  153. X    make am
  154. X    am ant.test.mk
  155. X    
  156. X    Like much of Posix, obfuscation has its place.  Your task is to
  157. X    figure out where.
  158. X
  159. X    This entry comes complete with a Posix-like command description.
  160. X    Interested Posix balloters should lobby the IEEE for an obfuscated 
  161. X    P1003 sub-committee.
  162. X
  163. X    We also suggest that you try:
  164. X    make am
  165. X    am Makefile am_clobber        <-- clobber everything except am
  166. X    am Makefile all
  167. X
  168. X
  169. XSelected notes from the author:
  170. X
  171. X    See the file ant.README.
  172. END_OF_FILE
  173.   if test 656 -ne `wc -c <'1992/ant.hint'`; then
  174.     echo shar: \"'1992/ant.hint'\" unpacked with wrong size!
  175.   fi
  176.   # end of '1992/ant.hint'
  177. fi
  178. if test -f '1992/buzzard.2.README' -a "${1}" != "-c" ; then 
  179.   echo shar: Will not clobber existing file \"'1992/buzzard.2.README'\"
  180. else
  181.   echo shar: Extracting \"'1992/buzzard.2.README'\" \(756 characters\)
  182.   sed "s/^X//" >'1992/buzzard.2.README' <<'END_OF_FILE'
  183. Xbuzzard.2.README    this file
  184. Xbuzzard.2.design    description of FIRST (design documentation of THIRD)
  185. Xthird            implementation of THIRD in FIRST
  186. Xhelp.th            online listing of THIRD primitives
  187. X
  188. X    FIRST demos:  use  'first < {demo}'
  189. X
  190. Xdemo1.1st        prints Hello World! assuming ASCII
  191. X
  192. X    THIRD demos:  use  'cat third {demo} | first'
  193. X
  194. Xdemo1.th        prints Hello World! regardless of character set
  195. Xdemo2.th        demonstrates a simple loop
  196. Xdemo3.th        demonstrates a simple if test
  197. Xdemo4.th        recursive factorial calculating on the way up
  198. Xdemo5.th        recursive factorial calculating on the way down
  199. Xdemo6.th        demonstrates switching from compiler to execution mode
  200. X
  201. X    Interactive THIRD: use 'cat third - | first'.
  202. X
  203. X    To include the primitive on-line help, use
  204. X    'cat third help.th - | first'.
  205. END_OF_FILE
  206.   if test 756 -ne `wc -c <'1992/buzzard.2.README'`; then
  207.     echo shar: \"'1992/buzzard.2.README'\" unpacked with wrong size!
  208.   fi
  209.   # end of '1992/buzzard.2.README'
  210. fi
  211. if test -f '1992/buzzard.2.c' -a "${1}" != "-c" ; then 
  212.   echo shar: Will not clobber existing file \"'1992/buzzard.2.c'\"
  213. else
  214.   echo shar: Extracting \"'1992/buzzard.2.c'\" \(791 characters\)
  215.   sed "s/^X//" >'1992/buzzard.2.c' <<'END_OF_FILE'
  216. X#define c m[m[0]++] =
  217. X#define z;break;case
  218. X
  219. Xchar s[5000];
  220. Xint m[20000]={32},L=1,I,T[500],*S=T,t=64,w,f;
  221. X
  222. Xa(x)
  223. X{
  224. X   c L;
  225. X   L= *m-1;
  226. X   c t;
  227. X   c x;
  228. X   scanf("%s",s+t);
  229. X   t+=strlen(s+t)+1;
  230. X}
  231. X
  232. Xr(x)
  233. X{
  234. X   switch(m[x++]){
  235. X    z 5:    for(w=scanf("%s",s)<1?exit(0),0:L;strcmp(s,&s[m[w+1]]);w=m[w]);
  236. X        w-1 ? r(w+2) : (c 2,c atoi(s))
  237. X    z 12:    I=m[m[1]--]
  238. X    z 15:    f=S[-f]
  239. X    z 1:    c x 
  240. X    z 9:    f *=* S--
  241. X    z 7:    m[f]= *S--;
  242. X        f= *S--
  243. X    z 0:    *++S=f;
  244. X        f=m[I++]
  245. X    z 8:    f= *S --- f
  246. X    z 2:    m[++m[1]]=I;
  247. X        I=x
  248. X    z 11:    f=0>f
  249. X    z 4:    *m-=2;c 2
  250. X    z 6:    f=m[f]
  251. X    z 10:    f= *S--/f
  252. X    z 3:    a(1);
  253. X        c 2
  254. X    z 13:    putchar(f);
  255. X        f= *S--
  256. X    z 14:    *++S=f;
  257. X        f=getchar();
  258. X   }
  259. X}
  260. X
  261. Xmain()
  262. X{
  263. X   a(3);
  264. X   a(4);
  265. X   a(1);
  266. X   w= *m;
  267. X   c 5;
  268. X   c 2;
  269. X   I= *m;
  270. X   c w;
  271. X   c I-1;
  272. X   for(w=6;w<16;)
  273. X      a(1),c w++;
  274. X   m[1]= *m;
  275. X   for(*m+=512;;r(m[I++]));
  276. X}
  277. END_OF_FILE
  278.   if test 791 -ne `wc -c <'1992/buzzard.2.c'`; then
  279.     echo shar: \"'1992/buzzard.2.c'\" unpacked with wrong size!
  280.   fi
  281.   # end of '1992/buzzard.2.c'
  282. fi
  283. if test -f '1992/demo1.th' -a "${1}" != "-c" ; then 
  284.   echo shar: Will not clobber existing file \"'1992/demo1.th'\"
  285. else
  286.   echo shar: Extracting \"'1992/demo1.th'\" \(34 characters\)
  287.   sed "s/^X//" >'1992/demo1.th' <<'END_OF_FILE'
  288. X: demo1 " Hello world!
  289. X" ;
  290. X
  291. Xdemo1
  292. END_OF_FILE
  293.   if test 34 -ne `wc -c <'1992/demo1.th'`; then
  294.     echo shar: \"'1992/demo1.th'\" unpacked with wrong size!
  295.   fi
  296.   # end of '1992/demo1.th'
  297. fi
  298. if test -f '1992/demo2.th' -a "${1}" != "-c" ; then 
  299.   echo shar: Will not clobber existing file \"'1992/demo2.th'\"
  300. else
  301.   echo shar: Extracting \"'1992/demo2.th'\" \(135 characters\)
  302.   sed "s/^X//" >'1992/demo2.th' <<'END_OF_FILE'
  303. X: demo2 
  304. X
  305. X    10 0        ( iterate from 0 stopping before 10 )
  306. X    do
  307. X        i .      ( print the loop counter )
  308. X    loop
  309. X    cr        ( add a newline )
  310. X;
  311. X
  312. Xdemo2
  313. END_OF_FILE
  314.   if test 135 -ne `wc -c <'1992/demo2.th'`; then
  315.     echo shar: \"'1992/demo2.th'\" unpacked with wrong size!
  316.   fi
  317.   # end of '1992/demo2.th'
  318. fi
  319. if test -f '1992/demo3.th' -a "${1}" != "-c" ; then 
  320.   echo shar: Will not clobber existing file \"'1992/demo3.th'\"
  321. else
  322.   echo shar: Extracting \"'1992/demo3.th'\" \(245 characters\)
  323.   sed "s/^X//" >'1992/demo3.th' <<'END_OF_FILE'
  324. X: printfour
  325. X
  326. X    dup        ( save the number on top of the stack )
  327. X    4 =        ( compare it to four )
  328. X    if
  329. X      " forth "    ( output a string for it )
  330. X      drop        ( and delete the saved value )
  331. X        else
  332. X      .
  333. X    endif
  334. X;
  335. X
  336. X: demo3 10 0 do i printfour loop cr ;
  337. X
  338. Xdemo3
  339. END_OF_FILE
  340.   if test 245 -ne `wc -c <'1992/demo3.th'`; then
  341.     echo shar: \"'1992/demo3.th'\" unpacked with wrong size!
  342.   fi
  343.   # end of '1992/demo3.th'
  344. fi
  345. if test -f '1992/demo4.th' -a "${1}" != "-c" ; then 
  346.   echo shar: Will not clobber existing file \"'1992/demo4.th'\"
  347. else
  348.   echo shar: Extracting \"'1992/demo4.th'\" \(439 characters\)
  349.   sed "s/^X//" >'1992/demo4.th' <<'END_OF_FILE'
  350. X( compute factorial recursively )
  351. X( take x as input, return x! and x as output )
  352. X
  353. X: fact-help
  354. X
  355. X  dup if
  356. X    1 -            ( leave x-1 on top )
  357. X    fact-help        ( leave x-1, [x-1]! )
  358. X    1 +            ( leave x, [x-1]!, x )
  359. X    swap over swap    ( leave [x-1]!, x, x )
  360. X    *            ( into x!, x )
  361. X    swap        ( into x, x! )
  362. X  else
  363. X    1 swap
  364. X  then
  365. X;
  366. X
  367. X: fact
  368. X
  369. X  fact-help
  370. X  drop
  371. X
  372. X;
  373. X
  374. X: demo4
  375. X  " 4 factorial is: " 4 fact . cr
  376. X  " 6 factorial is: " 6 fact . cr
  377. X;
  378. X
  379. Xdemo4
  380. END_OF_FILE
  381.   if test 439 -ne `wc -c <'1992/demo4.th'`; then
  382.     echo shar: \"'1992/demo4.th'\" unpacked with wrong size!
  383.   fi
  384.   # end of '1992/demo4.th'
  385. fi
  386. if test -f '1992/demo5.th' -a "${1}" != "-c" ; then 
  387.   echo shar: Will not clobber existing file \"'1992/demo5.th'\"
  388. else
  389.   echo shar: Extracting \"'1992/demo5.th'\" \(339 characters\)
  390.   sed "s/^X//" >'1992/demo5.th' <<'END_OF_FILE'
  391. X( recursive factorial.  given x on top, followed by )
  392. X( an "accumulator" containing the product except for x! )
  393. X
  394. X: fact-help2
  395. X
  396. X  dup if
  397. X    swap over swap
  398. X    *
  399. X    swap 1 -
  400. X    fact-help2
  401. X  then
  402. X;
  403. X
  404. X: fact
  405. X
  406. X  1 swap
  407. X  fact-help2
  408. X  drop
  409. X;
  410. X
  411. X: demo5
  412. X
  413. X  " The factorial of 3 is: " 3 fact . cr
  414. X  " The factorial of 5 is: " 5 fact . cr
  415. X;
  416. X
  417. Xdemo5
  418. END_OF_FILE
  419.   if test 339 -ne `wc -c <'1992/demo5.th'`; then
  420.     echo shar: \"'1992/demo5.th'\" unpacked with wrong size!
  421.   fi
  422.   # end of '1992/demo5.th'
  423. fi
  424. if test -f '1992/demo6.th' -a "${1}" != "-c" ; then 
  425.   echo shar: Will not clobber existing file \"'1992/demo6.th'\"
  426. else
  427.   echo shar: Extracting \"'1992/demo6.th'\" \(388 characters\)
  428.   sed "s/^X//" >'1992/demo6.th' <<'END_OF_FILE'
  429. X: foobar
  430. X  2
  431. X  [ 2 ,          ( '[' turns the compiler off, allowing us to execute code )
  432. X    1 1 1 + + ,   ( and we compile in-line a 2 and a three )
  433. X          ( the '2' means 'push the number following this' )
  434. X  ]
  435. X  + . cr
  436. X;
  437. X
  438. Xfoobar
  439. X
  440. X: 'foobar ' foobar ;    ( ' can only be run inside the compiler )
  441. X            ( ' leaves the address of the following word
  442. X                on the stack )
  443. X
  444. X'foobar . cr
  445. X
  446. X'foobar dump
  447. END_OF_FILE
  448.   if test 388 -ne `wc -c <'1992/demo6.th'`; then
  449.     echo shar: \"'1992/demo6.th'\" unpacked with wrong size!
  450.   fi
  451.   # end of '1992/demo6.th'
  452. fi
  453. if test -f '1992/westley.c' -a "${1}" != "-c" ; then 
  454.   echo shar: Will not clobber existing file \"'1992/westley.c'\"
  455. else
  456.   echo shar: Extracting \"'1992/westley.c'\" \(305 characters\)
  457.   sed "s/^X//" >'1992/westley.c' <<'END_OF_FILE'
  458. X           main(l
  459. X      ,a,n,d)char**a;{
  460. X  for(d=atoi(a[1])/10*80-
  461. X atoi(a[2])/5-596;n="@NKA\
  462. XCLCCGZAAQBEAADAFaISADJABBA^\
  463. XSNLGAQABDAXIMBAACTBATAHDBAN\
  464. XZcEMMCCCCAAhEIJFAEAAABAfHJE\
  465. XTBdFLDAANEfDNBPHdBcBBBEA_AL\
  466. X H E L L O,    W O R L D! "
  467. X   [l++-3];)for(;n-->64;)
  468. X      putchar(!d+++33^
  469. X           l&1);}
  470. END_OF_FILE
  471.   if test 305 -ne `wc -c <'1992/westley.c'`; then
  472.     echo shar: \"'1992/westley.c'\" unpacked with wrong size!
  473.   fi
  474.   # end of '1992/westley.c'
  475. fi
  476. echo shar: End of archive 5 \(of 5\).
  477. cp /dev/null ark5isdone
  478. MISSING=""
  479. for I in 1 2 3 4 5 ; do
  480.     if test ! -f ark${I}isdone ; then
  481.     MISSING="${MISSING} ${I}"
  482.     fi
  483. done
  484. if test "${MISSING}" = "" ; then
  485.     echo You have unpacked all 5 archives.
  486.     rm -f ark[1-9]isdone
  487. else
  488.     echo You still must unpack the following archives:
  489.     echo "        " ${MISSING}
  490. fi
  491. exit 0
  492. exit 0 # Just in case...
  493.