home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3031 < prev    next >
Encoding:
Internet Message Format  |  1991-03-09  |  30.0 KB

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