home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / C / ioccc / 1990-Obfuscated-C-Code-Contest.2.2 < prev    next >
Encoding:
Internet Message Format  |  1992-10-18  |  30.4 KB

  1. Path: usage.csd.unsw.oz.au!metro!munnari.oz.au!samsung!uakari.primate.wisc.edu!dali.cs.montana.edu!ogicse!ucsd!pacbell.com!pacbell!rtech!cpsc6a!hoptoad!chongo
  2. From: chongo@hoptoad.uucp (Landon C. Noll)
  3. Newsgroups: comp.lang.c,comp.sources.d,comp.unix.internals,alt.sources,misc.misc
  4. Subject: 1990 International Obfuscated C Code Contest winners 2 of 2
  5. Message-ID: <15948@hoptoad.uucp>
  6. Date: 8 Mar 91 14:18:08 GMT
  7. Expires: 15 May 91 00:00:00 GMT
  8. Organization: Nebula Consultants in San Francisco
  9. Lines: 878
  10. Xref: usage.csd.unsw.oz.au comp.lang.c:14679 comp.sources.d:4247 comp.unix.internals:2391 alt.sources:1445 misc.misc:1609
  11.  
  12. References: 
  13. Sender: 
  14. Reply-To: chongo@hoptoad.UUCP (Landon C. Noll)
  15. Followup-To: 
  16. Distribution: world
  17. Organization: Nebula Consultants in San Francisco
  18. Keywords: 
  19.  
  20. Submitted-by: chongo@toad.com (Landon Curt Noll)
  21. #
  22. # Send comments, questions, bugs to: 
  23. #
  24. #    judges@toad.com   -or-   ...!{sun,uunet,utzoo,pyramid}!hoptoad!judges
  25. #
  26. # You are strongly encouraged to read the new contest rules before
  27. # sending any entries.  The rules, and sometimes the contest Email
  28. # address itself, change over time.  A valid entry one year may
  29. # be rejected in a later year due to changes in the rules.  The typical
  30. # start date for a contest is early March.  The typical end date for a
  31. # contest is late May.
  32. #
  33. # The contest rules are posted to comp.unix.wizards, comp.lang.c,
  34. # misc.misc, alt.sources and comp.sources.d.  If you do not have access 
  35. # to these groups, or if you missed the early March posting, you may 
  36. # request a copy from the judges, via Email, at the address above.
  37. #
  38. Archive-name: ioccc.1990/part02
  39.  
  40. ---- Cut Here and unpack ----
  41. #!/bin/sh
  42. # This is part 02 of ioccc.1990
  43. if touch 2>&1 | fgrep 'amc' > /dev/null
  44.  then TOUCH=touch
  45.  else TOUCH=true
  46. fi
  47. # ============= 1990/jaw.hint ==============
  48. echo "x - extracting 1990/jaw.hint (Text)"
  49. sed 's/^X//' << 'SHAR_EOF' > 1990/jaw.hint &&
  50. XBest Entropy-reducer: <see below> Woods, Fox & Eggert
  51. X
  52. X    James A. Woods                     jaw@riacs.edu
  53. X    Research Institute for Advanced Computer Science
  54. X    MS 230-5
  55. X    NASA Ames Research Center
  56. X    Moffett Field, CA 94131
  57. X    USA
  58. X
  59. X    Karl F. Fox                     karl@MorningStar.com
  60. X    Morning Star Technologies, Inc.
  61. X    1760 Zollinger Road
  62. X    Columbus, OH 43221
  63. X    USA
  64. X
  65. X    Paul Eggert                     eggert@twinsun.com
  66. X    Twin Sun Inc.
  67. X    360 N. Sepulveda Blvd. #2055
  68. X    El Segundo, CA 90245
  69. X    USA
  70. X
  71. X
  72. XJudges' comments:
  73. X
  74. X    The program, in its base form, implements two useful utilities:
  75. X
  76. X    atob - ascii to binary conversion
  77. X    zcat - decompression filter
  78. X
  79. X    To test the official C entry, one might try:
  80. X
  81. X    echo "Quartz glyph jocks vend, fix, BMW." | compress | btoa | jaw
  82. X
  83. X    which should apply the identity transformation to a minimal
  84. X    holoalphabetic sentence.
  85. X
  86. X    Included with this entry is a shell script (with comments edited down
  87. X    to reduce it to 1530 bytes) which implements the complete
  88. X    shark utility.  The script, shark.sh, contains a 'jaw.c' embedded
  89. X    within it!
  90. X
  91. X    The sender must have 'compress' and 'btoa'.  To send, try:
  92. X
  93. X    sh shark.sh jaw.* > receive
  94. X
  95. X    The resulting file, 'receive', unpacks the input files
  96. X    even if the receiver lacks 'uncompress' and 'atob':
  97. X
  98. X    mkdir test
  99. X    cd test
  100. X    sh ../receive
  101. X    cmp ../jaw.c jaw.c
  102. X    cmp ../jaw.hint jaw.hint
  103. X
  104. XSelected notes from the authors:
  105. X
  106. X                 ABSTRACT
  107. X
  108. X           Minimal, Universal File Bundling
  109. X     (or, Functional Obfuscation in a Self-Decoding Unix Shell Archive)
  110. X
  111. X               James A. Woods
  112. X           Universities Space Research Association
  113. X              NASA Ames Research Center
  114. X
  115. X
  116. X           "Use an algorithm, go to jail."
  117. X                [anon., circa 1988, pre-Morris worm era]
  118. X
  119. X
  120. X      Myriad formats have been proposed for  network-mailable
  121. X     data.  A major difficulty undermining the popularity of most
  122. X     file/message bundlers  is  that  the  sender  assumes  prior
  123. X     installation  of  the  computational  dual  of such bundling
  124. X     software by the receiver.  Command shell archives  alleviate
  125. X     this problem somewhat, but still require standardization for
  126. X     the  function  of  data  compression  and  mail-transparency
  127. X     encoding.  On Unix, these coding format quandaries are over-
  128. X     come by planting a novel Trojan Horse in the archive  header
  129. X     to perform negotiationless decoding.
  130. X
  131. X      Specifically, we outline the development of an extraor-
  132. X     dinarily   compact  portable  (un)bundler  to  (dis)assemble
  133. X     data-compressed,  binary-to-ASCII-converted,   length-split,
  134. X     and  checksummed  directory  structures  using standard Unix
  135. X     tools.  Miniature versions of counterparts to  a  Lempel-Ziv
  136. X     coder ('compress' or 'squeeze') and an efficient bit packet-
  137. X     izer ('btoa') are compiled on-the-fly  at  mail  destination
  138. X     sites  where  they may not already exist.  These are written
  139. X     in purposefully obfuscated-C to  accompany  similarly-shrunk
  140. X     shell command glue.  This resulting shell archiver is dubbed
  141. X     'shark'.
  142. X
  143. X       'Shark' procedure overhead consumes as  few  as  three
  144. X     dozen  shell  lines  (or ~1100 bytes), commensurate with the
  145. X     size of many Internet mail headers; it  amortizes  favorably
  146. X     with  message  size.   'Shark' is portable across Unix vari-
  147. X     ants, while the underlying technique is inherently  general-
  148. X     izable to other encoding schemes.
  149. X
  150. X      In   the   function-theoretic    sense    of    minimal
  151. X     Chaitin/Kolmogorov complexity, and within a modified Shannon
  152. X     model of communication, the 'shark' effort aims to construct
  153. X     a  "shortest  program"  for  source  decoding in the Turing-
  154. X     universal Unix environment.
  155. X
  156. X     ----------------------------------------------
  157. X
  158. X       Oh, the shark has pretty teeth, dear--
  159. X       And he shows them pearly white
  160. X       Just a jackknife has Macheath, dear--
  161. X       And he keeps it out of sight.
  162. X
  163. X            [Bertolt Brecht, Threepenny Opera]
  164. X
  165. X     ----------------------------------------------
  166. X
  167. X    We have ported this program to a wide variety of systems.  Among
  168. X    these are:
  169. X
  170. X    SunOS 4.1 / Sun Sparcstation 1 (using both 'cc' and 'gcc 1.37.1')
  171. X    SunOS 4.0.3 / Sun 3
  172. X    BSD 4.3 / VAX 8650
  173. X    SEIUX / Sumitomo Electric Ustation/S
  174. X    Sony NEWS-OS 3.3 / Sony NEWS (fairly vanilla 4.3BSD)
  175. X    System V.? / Hitachi 2050
  176. X    System V.? / NEC EWS 4800
  177. X    UNIOS-B / Omron Luna
  178. X    Dynix / Sequent Balance ('cc' for Natl. Semi. base + 'gcc 1.36')
  179. X    Unicos / Cray 2
  180. X
  181. X     We (the authors) feel this program is obfuscated for the
  182. X     following reasons:
  183. X
  184. X     (0) This is one of the few programs you'll see WHOSE VERY UTILITY
  185. X     DEPENDS ON ITS OBFUSCATION!
  186. X
  187. X     (1) The contest entry may be used to send its wonderful self to
  188. X     anyone in the Unix world!  Virus writers need not apply...
  189. X
  190. X     (2) The basic idea is twisted enough to be patentable, but is,
  191. X     out of the kindness of our hearts (as well as to maintain
  192. X     eligibility for the large IOCCC prize fund), dedicated to
  193. X     the public domain.  Claude Shannon, meet Alan Turing.
  194. X
  195. X     (3) Meta-obfuscation is via obfuscated description (see ABSTRACT).
  196. X
  197. X     (4) "Literary" allusion.  Production code contains a reference to
  198. X     self-reference, preserved at amazing cost for sheer perversity.
  199. X
  200. X     (5) Many, many micro obfuscations below, honed over three years
  201. X     time, in shell as well as C.  Ask about the 'tar' pit escape,
  202. X     the argv[0] flip, Paul's &4294967295 portability hack, the
  203. X     "void where prohibited by flaw" fix, the scanf() spacesaver,
  204. X     shift shenanigans, signal madness, exit()ing stage left, and
  205. X     source-to-source transformations galore.
  206. X
  207. X     For extra credit:
  208. X
  209. X    Construct 'sharkmail', to auto-split sharkives into mailable
  210. X    segments and mail them.  Here's a simple one, which could be
  211. X    extended to enable auto-reassembly with one shell cmd at the
  212. X    far end.
  213. X
  214. X     ------------------------ cut here for sharkmail -----------------------
  215. X     #!/bin/sh
  216. X     m=$1; shift
  217. X     shark $* | split -800 - /tmp/shark$$
  218. X     n=`ls /tmp/shark$$* | wc -l | sed 's/  *//'`
  219. X     p=0
  220. X     for f in `ls /tmp/shark$$*`
  221. X     do
  222. X     p=`expr $p + 1`
  223. X     mail -s "bundle ($p of $n) from '`whoami`'" $m < $f
  224. X     done
  225. X     rm /tmp/shark$$*
  226. X     ------------------------ end of sharkmail -----------------------------
  227. X
  228. X
  229. XShark history:
  230. X
  231. X       May 1987: Karl Fox introduces 1023-byte zcat.c to USENET.
  232. X         It's too late for the 4th IOCCC.
  233. X
  234. X       May 21, 1987: James A. Woods extends idea to construct self
  235. X         decompressing shar Trojan horse, utilizing 'cc', 'shar',
  236. X         'zcat', & 'atob'; size: 2303 bytes.
  237. X
  238. X       May 23, 1987: 'jaw' trims 250 bytes without much thought.
  239. X
  240. X       June 2, 1987: 52 lines of shell, 1991 bytes, now made with 'tar',
  241. X         short-circuit C-compile at far end, dual-use main.c,
  242. X         portability mods. (jaw)
  243. X
  244. X       Mar-May 1988: abortive run at 5th IOCCC.
  245. X         jaw.c - 1529 bytes.  compile line: 152 bytes.
  246. X         generated funny code with execvp() to invoke shell.
  247. X
  248. X       Aug 29, 1988: production version, now at 1830 bytes.
  249. X
  250. X       Jan 1990: Paul Eggert does tour-de-force shark re-engineering.
  251. X
  252. X       May 24, 1990: collaboration yields 999-byte jaw.c core (see above)
  253. X         and 1530-byte production shell code (w/comments).
  254. X         Eggert comes through with lion's share of improvements.
  255. X         7th IOCCC code now faster than the atob/zcat it replaces.
  256. X
  257. X       May 1990: 'jaw' develops experimental replacement using
  258. X         Dan Bernstein's high-compression 'squeeze'.
  259. X
  260. X
  261. XTo which we add:
  262. X
  263. X       June 1990: 'shark' wins the IOCCC, finally!  :-)
  264. SHAR_EOF
  265. $TOUCH -am 0922163990 1990/jaw.hint &&
  266. chmod 0444 1990/jaw.hint ||
  267. echo "restore of 1990/jaw.hint failed"
  268. set `wc -c 1990/jaw.hint`;Wc_c=$1
  269. if test "$Wc_c" != "7401"; then
  270.     echo original size 7401, current size $Wc_c
  271. fi
  272. # ============= 1990/pjr.hint ==============
  273. echo "x - extracting 1990/pjr.hint (Text)"
  274. sed 's/^X//' << 'SHAR_EOF' > 1990/pjr.hint &&
  275. X
  276. XMost Unusual Data Structure <pjr@pyra.co.uk> Peter J Ruczynski
  277. X
  278. X    Peter J Ruczynski.
  279. X    Pyramid Technology Ltd.
  280. X    Pyramid House,
  281. X    Solatron Road
  282. X    Farnborough.
  283. X    Hants GU14 7PL
  284. X    England, U.K.
  285. X
  286. X
  287. XJudges' comments:
  288. X
  289. X    This program prints out a string.  Can you figure out how
  290. X    it is done?
  291. X
  292. X    By use of pointers to functions returning a struct of pointers 
  293. X    to functions!
  294. X
  295. X    Note that some compilers will be unable to compile the
  296. X    expression 'X=g()...' in main due to lack of temporary
  297. X    value space.  One might want to try replacing main with:
  298. X
  299. X        main(){X=s().v().o().o().l().S().d().l().i().o().w().N();}
  300. X    
  301. X    if this is a problem.
  302. X
  303. X
  304. XSpoiler: (rot13 to read)
  305. X
  306. X    Guvf cebtenz cevagf bhg gur fgevat:
  307. X
  308. X    gur dhvpx oebja sbk whzcrq bire gur ynml qbt
  309. X
  310. X    ol hfr bs cbvagref gb shapgvbaf ergheavat n fgehpg bs cbvagref 
  311. X    gb shapgvbaf!
  312. X
  313. X
  314. XSelected notes from the author: (rot13 to read)
  315. X
  316. X    Vg vf fvzcyr gb znxr gur cebtenz cevag bgure fgevatf.  Rnpu
  317. X    nycunorgvpny punenpgre sebz n gb m vf cevagrq bhg nf vgf
  318. X    bccbfvgr:
  319. X
  320. X        n->m o->l p->k rgp
  321. X
  322. X    Gb rapbqr n arj fgevat vachg gur fgevat nf vg vf zrnag gb pbzr bhg:
  323. X
  324. X        K=f().i().b().b().y().F().q().y().v().b().j().A();
  325. X
  326. X    Abgr: F() ercerfragf n fcnpr naq A() n arjyvar.  Guvf jvyy abj
  327. X    cebqhpr...
  328. X
  329. X        uryyb jbeyq
  330. X
  331. X    By the way, there is actually a piece of code which is not used
  332. X    in the original program! I leave it as an intellectual exercise
  333. X    to the reader to find out what it is.
  334. X
  335. SHAR_EOF
  336. $TOUCH -am 0922163990 1990/pjr.hint &&
  337. chmod 0444 1990/pjr.hint ||
  338. echo "restore of 1990/pjr.hint failed"
  339. set `wc -c 1990/pjr.hint`;Wc_c=$1
  340. if test "$Wc_c" != "1479"; then
  341.     echo original size 1479, current size $Wc_c
  342. fi
  343. # ============= 1990/scjones.hint ==============
  344. echo "x - extracting 1990/scjones.hint (Text)"
  345. sed 's/^X//' << 'SHAR_EOF' > 1990/scjones.hint &&
  346. XANSI Committee's Worst Abuse of C: <scjones@sdrc.uu.net> Larry Jones
  347. X
  348. X    Larry Jones
  349. X    SDRC
  350. X    2000 Eastman Dr
  351. X    Milford, OH 45150  
  352. X    USA
  353. X
  354. X
  355. XJudges' comments:
  356. X
  357. X    The addition of trigraphs has made it easier to make programs 
  358. X    hard to read.  It was a dark and stormy night for C when the
  359. X    ANSI C committee added trigraphs to the standard.  Too bad
  360. X    that they didn't just simply require a more reasonable ISO
  361. X    character set.
  362. X
  363. X    The common.mk (non-ANSI) makefile uses sed to form scjones.alt.c.
  364. X    The scjones.alt.c is similar to the original scjones.c source,
  365. X    but with all the trigraphs converted.  You might want to try:
  366. X
  367. X        make -f common.mk scjones.alt.c
  368. X
  369. X    even if you only have an ANSI compiler, just to see how
  370. X    the trigrapsh are converted.
  371. X
  372. XWARNING: In the future, we will be passing ANSI programs through a
  373. X     trigraph filter before reading.  Trigraph-ifacation will
  374. X     not be a major consideration in future contests.  People 
  375. X     should exploit more interesting features of ANSI C.
  376. X
  377. X
  378. XSelected notes from the author:
  379. X
  380. X    Since this year's contest is dedicated to ANSI C, here is a
  381. X    strictly conforming entry.  In accordance with the ANSI
  382. X    definition of a strictly conforming program it does not produce
  383. X    output dependent on any unspecified, undefined, or implementation
  384. X    defined behavior, and it does not exceed any of the minimum
  385. X    implementation limits.  It adheres to all of the syntactic and
  386. X    semantic constraints of the standard, #includes the relevant
  387. X    headers for the functions it uses, and uses the EXIT_SUCCESS and
  388. X    EXIT_FAILURE macros to return a correct success/fail status to
  389. X    the invoking program.  It also uses trigraphs for characters
  390. X    which are not in the Invariant Code Set of ISO 646:1983, so it
  391. X    will be portable to machines with deficient (from C's standpoint)
  392. X    character sets.  In short, it should be very widely portable.  As
  393. X    an extra added attraction, all of the lines are under 72
  394. X    characters long, which would allow for sequence numbers to be
  395. X    punched in columns 73-80 :-).
  396. X
  397. X    [[ The Author sent us this note after he was informed that he won ]]
  398. X
  399. X    Although I am quite grateful for the "ANSI Committee's Worst Abuse
  400. X    of C" title (were you aware that I am a member of the committee or
  401. X    is the double meaning unintentional?), I was really hoping for
  402. X    something more along the lines of "Closest Resemblance to Line Noise."  :-)
  403. X
  404. X    [[ ... it was unintentional ]]
  405. SHAR_EOF
  406. $TOUCH -am 0922163990 1990/scjones.hint &&
  407. chmod 0444 1990/scjones.hint ||
  408. echo "restore of 1990/scjones.hint failed"
  409. set `wc -c 1990/scjones.hint`;Wc_c=$1
  410. if test "$Wc_c" != "2466"; then
  411.     echo original size 2466, current size $Wc_c
  412. fi
  413. # ============= 1990/stig.hint ==============
  414. echo "x - extracting 1990/stig.hint (Text)"
  415. sed 's/^X//' << 'SHAR_EOF' > 1990/stig.hint &&
  416. XStrangest Abuse of the Rules: <stig@solan.unit.no> Stig Hemmer
  417. X
  418. X    Stig Hemmer
  419. X    Norwegian Institute of Technology
  420. X    N-7034 Trondheim-NTH
  421. X    Norway 
  422. X
  423. XJudges' comments:
  424. X
  425. X    We changed the alias that the author's suggested alias from a
  426. X    C-shell alias to a Korn shell alias because many C-shells
  427. X    did not allow Stig Hemmer's form of aliasing.  (The error 
  428. X    may have also been due to some uucp site corrupting his 
  429. X    entry) Below is the author's 'how to compile' sections as 
  430. X    mailed to us:
  431. X
  432. X    ---how to ANSI compile---
  433. X    Xecho alias c cc -E -o o.c shst.c -"\''Dc=main(){printf("\"N%sested E
  434. X    Ccomments allowed.\\n\",'/*/*/0*/**/'1?\"\":\"o n\"");}'\'';cc -o c o.c'
  435. X    Xsource shst.c"|csh
  436. X    ---how to common compile---
  437. X    Xecho alias c cc -E -o o.c shst.c -"\''Dc=main(){printf("\"N%sested E
  438. X    Ccomments allowed.\\n\",'/*/*/0*/**/'1?\"\":\"o n\"");}'\'';cc -o c o.c'
  439. X    Xsource shst.c"|csh
  440. X
  441. X    Note that shst.c is renamed to stig.c in the distribution.
  442. X
  443. X    Producing an equivalent C-shell alias or /bin/sh function
  444. X    is left as an exercise to the reader.
  445. X
  446. XWARNING: This program's 'how to compile' is too specific to a particular
  447. X     shell.  The obfuscation of this program to more related to
  448. X     shell obfuscation than C obfuscation.  This type of entry will 
  449. X     not be permitted in future contests.
  450. X
  451. XSelected notes from the author:
  452. X
  453. X    If you like shell programming you may also admire my
  454. X    creative quoting. (I use echo to create an alias
  455. X    which when run calls cc with the -D option to create a
  456. X    C macro with double quotes in it. ARRRRRGGGHHH!)
  457. X
  458. X    The program is totally portable, but the compile
  459. X    commands are very shell specific so don't be TOO mad
  460. X    at me if they don't work for you.
  461. X
  462. X    If you want to put these commands in a Makefile you
  463. X    must add 4 - four - backslashes at the end on first
  464. X    line. (At least that's what works here.)
  465. X
  466. X    If everything works correctly it create an executable
  467. X    named c which checks whether your compiler supports
  468. X    nested comments. I've stolen the "/*/*/0*/**/1" from
  469. X    somewhere so don't give me any points for it. Of
  470. X    course neither ANSI nor K&R support nested comments
  471. X    when properly implemented, but what the heck. 
  472. SHAR_EOF
  473. $TOUCH -am 0922163990 1990/stig.hint &&
  474. chmod 0444 1990/stig.hint ||
  475. echo "restore of 1990/stig.hint failed"
  476. set `wc -c 1990/stig.hint`;Wc_c=$1
  477. if test "$Wc_c" != "2213"; then
  478.     echo original size 2213, current size $Wc_c
  479. fi
  480. # ============= 1990/tbr.hint ==============
  481. echo "x - extracting 1990/tbr.hint (Text)"
  482. sed 's/^X//' << 'SHAR_EOF' > 1990/tbr.hint &&
  483. XBest Utility: <tbr@acm.princeton.edu, smd@att.research.com> Rakitzis & Dorward
  484. X
  485. X    Byron Rakitzis           Sean Dorward
  486. X    Princeton University   Princeton University
  487. X    5707 Old Lodge Dr.     10274 Burleigh Cottage Lane
  488. X    Houston, TX 77066      Ellicott City, MD 21043
  489. X    USA               USA
  490. X
  491. XJudges' comments:
  492. X
  493. X    This program implements a subject a well known Un*x utility whose 
  494. X    original source was considered to be extremely obfuscated by many
  495. X    people, excluding its author.  In fact, this utility one a major
  496. X    inspiration for the formation of this contest.
  497. X
  498. X    The author supplied us with a slightly smaller unformatted version
  499. X    of the program which we include below:
  500. X
  501. X    #define D ,close(
  502. X    char*c,q[512],m[256],*v[99],**u,*i[3];int f[2],p;main(){for(m[m[60]=m[62]=
  503. X    32]=m[*m=124[m]=9]=6;e(-8),gets(1+(c=q))||exit(0);r(0,0))for(;*++c;);}
  504. X    r(t,o){*i=i[2]=0;for(u=v+98;m[*--c]^9;m[*c]&32?i[*c&2]=
  505. X    *u,u-v^98&&++u:3)if(!m[*c]){for(*++c=0;!m[*--c];);*--u=
  506. X    ++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[1]:1,(p=fork())?e(p),o?
  507. X    r(o,0)D o)D*f):4,wait(0):(o?dup2(*f,0)D*f)D o):*i?1 D
  508. X    0),e(open(*i,0)):5,t?dup2(t,1)D t):i[2]?9 D
  509. X    1),e(creat(i[2],438)):2,e(execvp(*u,u))):e(chdir(u[1])*2):6;}
  510. X    e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||exit(1):5;}
  511. X    
  512. XSelected notes from the author: (rot13 to read)
  513. X
  514. X    Guvf cebtenz vf n ehqvzragnel furyy. Vg qbrf v/b erqverpgvba, cvcrf
  515. X    naq pq. Vg syntf reebef ba snvyrq puqve'f, bcra'f, perng'f
  516. X    rkrpic'f, sbex'f naq n srj flagnk reebef.
  517. X
  518. X    Guvf cebtenz vf boshfpngrq va n srj abgnoyr jnlf: ncneg sebz gur
  519. X    ynlbhg (na hasbeznggrq (ohg pehapurq) irefvba vf vapyhqrq sbe
  520. X    crbcyr jub jnag gb chg guvf guebhtu po) vg znxrf pyrire hfr bs n
  521. X    jevgr fgngrzrag, fb gung gur fnzr fgngrzrag pna or hfrq gb cevag
  522. X    reebef naq gur cebzcg. Ol pnyyvat gur reebe shapgvba jvgu gur inyhr
  523. X    -8, gur cbvagre bssfrg va gur rkcerffvba "?\a$ "-k/4 tbrf sebz 0 gb
  524. X    2.  Cerfgb!  N cebzcg. Sbe reebef jvgu ahzoref fznyyre guna -4
  525. X    (v.r., HAVK flfgrz pnyyf) n dhrfgvba znex vf cevagrq.
  526. X
  527. X    Gur reebe inyhr bs puqve vf qbhoyrq fb gung jr qba'g rkvg sebz gur
  528. X    cnerag furyy ba n puqve reebe (fvapr r() rkvgf ba -1 reebef bayl).
  529. X    Nyy bgure flfgrz pnyy snvyherf rkvg fvapr gurl ner sebz fhofuryyf.
  530. X
  531. X    Erphefvba vf farnxvyl rzcyblrq gb nibvq n frpbaq pnyy gb sbex(),
  532. X    naq gur yvar vf cnefrq va n snveyl ovmneer snfuvba:  onpxjneqf. Gur
  533. X    urneg bs gur cebtenz, gung vf, gur cneg juvpu cresbezf nyy sbexf,
  534. X    rkrpf, bcraf, rgp. vf BAR P FGNGRZRAG.
  535. X
  536. X    Gur zrgn-inyhrf neenl vf vavgvnyvmrq va n ovmneer snfuvba, naq gur
  537. X    fhofrdhrag purpxf sbe gur '<' naq '>' ner cresbezrq va n fvatyr
  538. X    fgngrzrag hfvat n znfx, fvapr lbh xabj gung '>'&2 vf 0, jurernf
  539. X    '<'&2 vf 2. Bgure fhpu zvpeb-boshfpngvbaf nobhaq.
  540. X
  541. X    Svanyyl, vg vf abgnoyr gung gur pbqr jnf unpxrq sbe zvavznyvgl. Vs
  542. X    lbh ybbx ng gur pbzcerffrq irefvba, lbh jvyy or uneq-cerffrq gb
  543. X    ryvzvangr zber guna n srj punenpgref (jr pna'g frr ubj gb znxr vg
  544. X    nal fznyyre!).  550 punenpgref vf cerggl yrna sbe n furyy gung qbrf
  545. X    guvf zhpu.
  546. X
  547. X    OHTF
  548. X
  549. X    Gur flagnk bs gur furyy unf abg orra shyyl rkcyberq, ohg vs lbh gel
  550. X    gb erqverpg va gur fnzr qverpgvba zber guna bapr, bayl bar
  551. X    erqverpgvba vf cresbezrq. Guvf vf n "srngher" bs gur jnl gur yvar
  552. X    vf cnefrq; n cbvagre gb gur fgnpx bs nethzragf vf nffvtarq naq na
  553. X    nethzrag vf fgbyra rirel gvzr n ">" be "<" vf rapbhagrerq.  Gur
  554. X    furyy syntf na reebe vs ab nethzragf ner ba gur fgnpx. Guhf, sbe
  555. X    rknzcyr:
  556. X        png > sbb > one
  557. X    pngf gb sbb, fvapr vg jnf chfurq ynfg, ohg
  558. X        png > > sbb one
  559. X    pngf gb one, fvapr one jnf chfurq haqre sbb. (erzrzore jr'er
  560. X    cnefvat evtug-yrsg)
  561. X
  562. X    Qrcraqvat ba lbhe synibe bs HA*K, pq jvgubhg na nethzrag jvyy
  563. X    rvgure cebqhpr na reebe be whfg qb abguvat.
  564. X
  565. X    Gurer vf whfg bar reebe zrffntr, gur dhrfgvba znex, ohg url, gung'f
  566. X    nyy rq qbrf gbb.
  567. SHAR_EOF
  568. $TOUCH -am 0922163990 1990/tbr.hint &&
  569. chmod 0444 1990/tbr.hint ||
  570. echo "restore of 1990/tbr.hint failed"
  571. set `wc -c 1990/tbr.hint`;Wc_c=$1
  572. if test "$Wc_c" != "3890"; then
  573.     echo original size 3890, current size $Wc_c
  574. fi
  575. # ============= 1990/theorem.hint ==============
  576. echo "x - extracting 1990/theorem.hint (Text)"
  577. sed 's/^X//' << 'SHAR_EOF' > 1990/theorem.hint &&
  578. XBest of Show: <theorem@blake.u.washington.edu> Adrian Mariano
  579. X
  580. X    Adrian Mariano
  581. X    University of Washington
  582. X    2729 72nd Ave SE
  583. X    Mercer Island, WA 98040
  584. X    USA
  585. X
  586. X
  587. XJudges' comments:
  588. X
  589. X    The program's source implements four functions, all from the
  590. X    same source file!
  591. X
  592. X    Usage:
  593. X
  594. X    theorem expression x1 x2 h y1
  595. X
  596. X    where:
  597. X        expression - function f(x,y)  (see below)
  598. X        x1 - start of interval
  599. X        x2 - end of interval
  600. X        h - step size
  601. X        y1 - initial value  (y(x1) == y1)
  602. X
  603. X    When you compile theorem.c as is and run with 5 args, it numerically
  604. X    solves the equation y'=f(x,y), with a step size of h, over the interval 
  605. X    x=[x1,x2], with the initial condition of y(x1)=y1.
  606. X
  607. X    The 'expression' f(x,y), is any function of 'x' and 'y' with the
  608. X    operators:
  609. X    
  610. X        +    -    *    /    ^
  611. X
  612. X    The symbol '^' is the power operator.  Note that it only supports
  613. X    integer powers.  Also note that all expressions are evaluated strictly 
  614. X    left to right.  (i.e., parenthesis aren't supported).
  615. X
  616. X    Try running the program with the following args:
  617. X
  618. X    theorem y 0 1 0.1 1
  619. X    theorem 1/x 1 2 0.1 0
  620. X    theorem 'x^2/y+x' 0 1 0.1 6
  621. X    
  622. X    But wait, there is more!  You also get, free of charge, a 
  623. X    reversing filter!  Try:
  624. X
  625. X    theorem -r 0 0 0 0 < theorem.c > sorter.c
  626. X    
  627. X    Still not impressed?  The author throws in for free, a 
  628. X    sort program! Try:
  629. X
  630. X    cc sorter.c -o sorter
  631. X    ls | sorter
  632. X    
  633. X    This program is safe for home use as well.  The author has
  634. X    included a safety feature in case you misplace the original
  635. X    program source:
  636. X
  637. X    sorter -r 0 0 0 0 < sorter.c > theorem_bkp.c
  638. X    
  639. X    And finally, as a special offer to users of this entry,
  640. X    the author provides a Fibonacci sequence generator!  Try:
  641. X
  642. X    sorter 0 0 0 0 < theorem.c > fibonacci.c
  643. X    cc fibonacci.c -o fibonacci
  644. X    fibonacci 1 1
  645. X    fibonacci 2 1
  646. X
  647. X    Program available 9 track and cartridge cassette.  Gensu knife
  648. X    not included!  :-)
  649. X
  650. X    When this program was first shown at the 1990 Summer Usenix 
  651. X    conference, it received a standing ovation; a first for
  652. X    a contest entry.
  653. X
  654. X    It should be noted that the 4 trailing args '0 0 0 0', are
  655. X    required on systems that dump core when NULL is dereferenced.
  656. X
  657. X
  658. XSelected notes from the author:
  659. X
  660. X    Differential equations are solved via the Runge-Kutta method, 
  661. X    which guarantees local error proportional to h^5, and total
  662. X    error across a finite interval is at most a constant times h^4.
  663. X    
  664. X    Sorting is accomplished with a standard shell sort.
  665. X
  666. X    Note that the sorting and reversing is limited to files with 
  667. X    fewer than 500 lines, each less than 99 characters long.  
  668. SHAR_EOF
  669. $TOUCH -am 0922163990 1990/theorem.hint &&
  670. chmod 0444 1990/theorem.hint ||
  671. echo "restore of 1990/theorem.hint failed"
  672. set `wc -c 1990/theorem.hint`;Wc_c=$1
  673. if test "$Wc_c" != "2585"; then
  674.     echo original size 2585, current size $Wc_c
  675. fi
  676. # ============= 1990/westley.hint ==============
  677. echo "x - extracting 1990/westley.hint (Text)"
  678. sed 's/^X//' << 'SHAR_EOF' > 1990/westley.hint &&
  679. XBest Layout: <...uunet!rosevax!jhereg!quest!digibd!merlyn> Merlyn LeRoy
  680. X
  681. X    Brian Westley (Merlyn LeRoy on usenet)
  682. X    DigiBoard, Inc.
  683. X    1026 Blair Ave.
  684. X    St. Paul, MN  55104  
  685. X    USA
  686. X
  687. XJudges' comments:
  688. X
  689. X    usage: westley <number>
  690. X
  691. X    If you would rather "Daisy" someone other than Westley, rename 
  692. X    the program as needed.  :-)
  693. X
  694. X    Read each block of code as if it were a piece of correspondence.
  695. X    For example, the first block of code would read:
  696. X
  697. X    charlie,
  698. X        doubletime me, OXFACE!
  699. X        not interested, get out
  700. X        mainly die, charly, *die*
  701. X            signed charlotte
  702. X
  703. X    The original source had control-L's after each code block.  To 
  704. X    make it easier on news readers, we converted each control-L to 
  705. X    a blank line.
  706. X
  707. X    Some ANSI compilers will not accept '1s' as a short integer - for
  708. X    these compilers replace the '1s' with '1'.
  709. X
  710. X
  711. XSelected notes from the author:
  712. X
  713. X    This is a "Picking the Daisy" simulation.  Now, instead of mangling a 
  714. X    daisy, simply run this program with the number of petals desired as 
  715. X    the argument.
  716. X    
  717. X    This is a good counter-example to peoples' complaints that C doesn't
  718. X    have an "English-like" syntax.
  719. X    
  720. X    Lint complains about everything - null effect, xxx may be used before
  721. X    set, statement not reached, return(e) and return.  Lint dumps core
  722. X    on some systems.  My personal favorite lint complaint is
  723. X    
  724. X        "warning: eroticism unused in function main".
  725. X    
  726. X    Also obviously, (char)lotte and (char*)lie are incompatible types...
  727. SHAR_EOF
  728. $TOUCH -am 0922163990 1990/westley.hint &&
  729. chmod 0444 1990/westley.hint ||
  730. echo "restore of 1990/westley.hint failed"
  731. set `wc -c 1990/westley.hint`;Wc_c=$1
  732. if test "$Wc_c" != "1489"; then
  733.     echo original size 1489, current size $Wc_c
  734. fi
  735. # ============= 1990/LANDER.BAS ==============
  736. echo "x - extracting 1990/LANDER.BAS (Text)"
  737. sed 's/^X//' << 'SHAR_EOF' > 1990/LANDER.BAS &&
  738. X10 REM Lunar Lander
  739. X20 REM By Diomidis Spinellis
  740. X30 PRINT "You aboard the Lunar Lander about to leave the spacecraft."
  741. X60 GOSUB 4000
  742. X70 GOSUB 1000
  743. X80 GOSUB 2000
  744. X90 GOSUB 3000
  745. X100 H = H - V
  746. X110 V = ((V + G) * 10 - U * 2) / 10
  747. X120 F = F - U
  748. X130 IF H > 0 THEN 80
  749. X135 H = 0
  750. X140 GOSUB 2000
  751. X150 IF V > 5 THEN 200
  752. X160 PRINT "Congratulations!  This was a very good landing."
  753. X170 GOSUB 5000
  754. X180 GOTO 10
  755. X200 PRINT "You have crashed."
  756. X210 GOTO 170
  757. X1000 REM Initialise
  758. X1010 V = 70
  759. X1020 F = 500
  760. X1030 H = 1000
  761. X1040 G = 2
  762. X1050 RETURN
  763. X2000 REM Print values
  764. X2010 PRINT "        Meter readings"
  765. X2015 PRINT "        --------------"
  766. X2020 PRINT "Fuel (gal):"
  767. X2030 PRINT F
  768. X2040 GOSUB 2100 + 100 * (H <> 0)
  769. X2050 PRINT V
  770. X2060 PRINT "Height (m):"
  771. X2070 PRINT H
  772. X2080 RETURN
  773. X2100 PRINT "Landing velocity (m/sec):"
  774. X2110 RETURN
  775. X2200 PRINT "Velocity (m/sec):"
  776. X2210 RETURN
  777. X3000 REM User input
  778. X3005 IF F = 0 THEN 3070
  779. X3010 PRINT "How much fuel will you use?"
  780. X3020 INPUT U
  781. X3025 IF U < 0 THEN 3090
  782. X3030 IF U <= F THEN 3060
  783. X3040 PRINT "Sorry, you have not got that much fuel!"
  784. X3050 GOTO 3010
  785. X3060 RETURN
  786. X3070 U = 0
  787. X3080 RETURN
  788. X3090 PRINT "No cheating please!  Fuel must be >= 0."
  789. X3100 GOTO 3010
  790. X4000 REM Detachment
  791. X4005 PRINT "Ready for detachment"
  792. X4007 PRINT "-- COUNTDOWN --"
  793. X4010 FOR I = 1 TO 11
  794. X4020   PRINT 11 - I
  795. X4025   GOSUB 4500
  796. X4030 NEXT I
  797. X4035 PRINT "You have left the spacecraft."
  798. X4037 PRINT "Try to land with velocity less than 5 m/sec."
  799. X4040 RETURN
  800. X4500 REM Delay
  801. X4510 FOR J = 1 TO 500
  802. X4520 NEXT J
  803. X4530 RETURN
  804. X5000 PRINT "Do you want to play again? (0 = no, 1 = yes)"
  805. X5010 INPUT Y
  806. X5020 IF Y = 0 THEN 5040
  807. X5030 RETURN
  808. X5040 PRINT "Have a nice day."
  809. SHAR_EOF
  810. $TOUCH -am 0922163990 1990/LANDER.BAS &&
  811. chmod 0444 1990/LANDER.BAS ||
  812. echo "restore of 1990/LANDER.BAS failed"
  813. set `wc -c 1990/LANDER.BAS`;Wc_c=$1
  814. if test "$Wc_c" != "1624"; then
  815.     echo original size 1624, current size $Wc_c
  816. fi
  817. # ============= 1990/stig.ksh ==============
  818. echo "x - extracting 1990/stig.ksh (Text)"
  819. sed 's/^X//' << 'SHAR_EOF' > 1990/stig.ksh &&
  820. Xalias c="cc -E stig.c -Dc='main(){printf(\"N%sested comments allowed.\\n"'",/*/*/0*/**/1?"":"o n"'");}'|grep -v '^#'>o.c;cc -o o o.c;o"
  821. SHAR_EOF
  822. $TOUCH -am 0922163990 1990/stig.ksh &&
  823. chmod 0444 1990/stig.ksh ||
  824. echo "restore of 1990/stig.ksh failed"
  825. set `wc -c 1990/stig.ksh`;Wc_c=$1
  826. if test "$Wc_c" != "136"; then
  827.     echo original size 136, current size $Wc_c
  828. fi
  829. # ============= 1990/shark.sh ==============
  830. echo "x - extracting 1990/shark.sh (Text)"
  831. sed 's/^X//' << 'SHAR_EOF' > 1990/shark.sh &&
  832. Xfor i in "${@?${usage?$0 file...}}";do<"$i"||exit;done
  833. X(cat&&tar cbf 1 - "$@"|compress|btoa&&echo w)<<\Z
  834. X#!/bin/sh
  835. X#
  836. X# GENTLE READER -- write this message to file [no headers!]; run "sh file".
  837. X#
  838. X# [un]shark: By James A. Woods.
  839. X# Seed planted by Karl Fox; code intensified by Paul Eggert.
  840. X#
  841. X# "Cleverly he dialed from within." -- D. Van Vliet, "Trout Mask Replica"
  842. X#
  843. XPATH=$PATH:. a=atob m=unshark z=zcat
  844. Xr="rm -f $a $m* $z" v="cc -o $z $m.c"
  845. Xtrap "$r;exit 1" 1 2 13 15
  846. Xecho decoding...
  847. X(:|compress|btoa|$a|$z)2>$m>&2||(sed '1,9s/./#define & /
  848. Xs/@/[w]/g
  849. Xs/C/char /g
  850. Xs/I/;if(/g
  851. Xs/W/;while(/g
  852. Xs/Y/%lx /g
  853. Xs/}/;}/g'>$m.c<<_&&
  854. XFX,perror("$m bite: resend"),1;
  855. XGgetC()
  856. XH(w=g())
  857. XK[69001]
  858. XPputC
  859. XQ256
  860. XU*p
  861. XXreturn 0
  862. XZw=QWw--)t@=0
  863. X#include<stdio.h>
  864. Xlong M,N,c,f,m,o,r,s,w;y(l){o^=l;m+=l+1;f=f*2+l+(f>>31&1)}int
  865. XO,S,e,i,k,n,q,t K;b(g){k=4Wg<k)y(P((C)(w>>--k*8)&255));w=0}CD K,h
  866. XK;main(g,V)C**V;{I**V-97)X,a()WG-10)W(g=G)+1&&g-'x')if(g-10)
  867. X{I4<k)b(0)Ig>32&g<'v')w=w*85+g-33,++k;else{Ig-'z'|k)F
  868. Xw=0;k=5}}WG-78)Iscanf("%ldYEYSYRY",&M,&N,&c,&s,&r)-5)F
  869. XIM){b(g=3-(M-1&3))Wg--)y(0)}I(M-N|c-o|s-m|r-f)&4294967295)F X}long
  870. Xg(){CUIm<f&n<k&&(m=(1l<<++n)-1)||O>=S){O=0;S=fread(D,1,n,stdin)*8IS<8)X-1;
  871. XS-=n-1}p=D+O/8;q=O&7;O+=n;X,(1<<8-q)-1&U>>q|m&((15<n+q)U[2]*Q|p[1]&255)<<8-q}
  872. Xa(){CU=D+Q;G;G;k=G;e=k>>7&1;k&=31Ik>16)F
  873. XZ,h@=w;n=8;f=Q+e;i=o=HIo<0)X,1;P(i)WH+1){Iw==Q&e){Z;m=n=8;f=QIH<0)X}
  874. Xc=wIw>=f)U++=i,w=oWw>=Q)U++=h@,w=t@;P(i=h@)Wp>D+Q)P(*--p)
  875. XI(w=f)<1l<<k)t@=o,h[f++]=i;o=c}X}
  876. X_
  877. X($v||$v -Mh)&&ln $z $a)&&$a<<\w>$m-&&$z<$m->$m&&tar xvf $m&&$r
  878. XZ
  879. SHAR_EOF
  880. $TOUCH -am 0922163990 1990/shark.sh &&
  881. chmod 0444 1990/shark.sh ||
  882. echo "restore of 1990/shark.sh failed"
  883. set `wc -c 1990/shark.sh`;Wc_c=$1
  884. if test "$Wc_c" != "1522"; then
  885.     echo original size 1522, current size $Wc_c
  886. fi
  887. exit 0
  888. -- 
  889. For a good prime, call:  391581 * 2^216193 - 1
  890.