home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / misc / 3923 < prev    next >
Encoding:
Text File  |  1992-09-10  |  13.5 KB  |  500 lines

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