1990 International Obfuscated C Code Contest winners 2 of 2
Landon C. Noll
chongo at hoptoad.uucp
Sat Mar 9 00:18:08 AEST 1991
References:
Sender:
Reply-To: chongo at hoptoad.UUCP (Landon C. Noll)
Followup-To:
Distribution: world
Organization: Nebula Consultants in San Francisco
Keywords:
Submitted-by: chongo at toad.com (Landon Curt Noll)
#
# Send comments, questions, bugs to:
#
# judges at toad.com -or- ...!{sun,uunet,utzoo,pyramid}!hoptoad!judges
#
# You are strongly encouraged to read the new contest rules before
# sending any entries. The rules, and sometimes the contest Email
# address itself, change over time. A valid entry one year may
# be rejected in a later year due to changes in the rules. The typical
# start date for a contest is early March. The typical end date for a
# contest is late May.
#
# The contest rules are posted to comp.unix.wizards, comp.lang.c,
# misc.misc, alt.sources and comp.sources.d. If you do not have access
# to these groups, or if you missed the early March posting, you may
# request a copy from the judges, via Email, at the address above.
#
Archive-name: ioccc.1990/part02
---- Cut Here and unpack ----
#!/bin/sh
# This is part 02 of ioccc.1990
if touch 2>&1 | fgrep 'amc' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
# ============= 1990/jaw.hint ==============
echo "x - extracting 1990/jaw.hint (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/jaw.hint &&
XBest Entropy-reducer: <see below> Woods, Fox & Eggert
X
X James A. Woods jaw at riacs.edu
X Research Institute for Advanced Computer Science
X MS 230-5
X NASA Ames Research Center
X Moffett Field, CA 94131
X USA
X
X Karl F. Fox karl at MorningStar.com
X Morning Star Technologies, Inc.
X 1760 Zollinger Road
X Columbus, OH 43221
X USA
X
X Paul Eggert eggert at twinsun.com
X Twin Sun Inc.
X 360 N. Sepulveda Blvd. #2055
X El Segundo, CA 90245
X USA
X
X
XJudges' comments:
X
X The program, in its base form, implements two useful utilities:
X
X atob - ascii to binary conversion
X zcat - decompression filter
X
X To test the official C entry, one might try:
X
X echo "Quartz glyph jocks vend, fix, BMW." | compress | btoa | jaw
X
X which should apply the identity transformation to a minimal
X holoalphabetic sentence.
X
X Included with this entry is a shell script (with comments edited down
X to reduce it to 1530 bytes) which implements the complete
X shark utility. The script, shark.sh, contains a 'jaw.c' embedded
X within it!
X
X The sender must have 'compress' and 'btoa'. To send, try:
X
X sh shark.sh jaw.* > receive
X
X The resulting file, 'receive', unpacks the input files
X even if the receiver lacks 'uncompress' and 'atob':
X
X mkdir test
X cd test
X sh ../receive
X cmp ../jaw.c jaw.c
X cmp ../jaw.hint jaw.hint
X
XSelected notes from the authors:
X
X ABSTRACT
X
X Minimal, Universal File Bundling
X (or, Functional Obfuscation in a Self-Decoding Unix Shell Archive)
X
X James A. Woods
X Universities Space Research Association
X NASA Ames Research Center
X
X
X "Use an algorithm, go to jail."
X [anon., circa 1988, pre-Morris worm era]
X
X
X Myriad formats have been proposed for network-mailable
X data. A major difficulty undermining the popularity of most
X file/message bundlers is that the sender assumes prior
X installation of the computational dual of such bundling
X software by the receiver. Command shell archives alleviate
X this problem somewhat, but still require standardization for
X the function of data compression and mail-transparency
X encoding. On Unix, these coding format quandaries are over-
X come by planting a novel Trojan Horse in the archive header
X to perform negotiationless decoding.
X
X Specifically, we outline the development of an extraor-
X dinarily compact portable (un)bundler to (dis)assemble
X data-compressed, binary-to-ASCII-converted, length-split,
X and checksummed directory structures using standard Unix
X tools. Miniature versions of counterparts to a Lempel-Ziv
X coder ('compress' or 'squeeze') and an efficient bit packet-
X izer ('btoa') are compiled on-the-fly at mail destination
X sites where they may not already exist. These are written
X in purposefully obfuscated-C to accompany similarly-shrunk
X shell command glue. This resulting shell archiver is dubbed
X 'shark'.
X
X 'Shark' procedure overhead consumes as few as three
X dozen shell lines (or ~1100 bytes), commensurate with the
X size of many Internet mail headers; it amortizes favorably
X with message size. 'Shark' is portable across Unix vari-
X ants, while the underlying technique is inherently general-
X izable to other encoding schemes.
X
X In the function-theoretic sense of minimal
X Chaitin/Kolmogorov complexity, and within a modified Shannon
X model of communication, the 'shark' effort aims to construct
X a "shortest program" for source decoding in the Turing-
X universal Unix environment.
X
X ----------------------------------------------
X
X Oh, the shark has pretty teeth, dear--
X And he shows them pearly white
X Just a jackknife has Macheath, dear--
X And he keeps it out of sight.
X
X [Bertolt Brecht, Threepenny Opera]
X
X ----------------------------------------------
X
X We have ported this program to a wide variety of systems. Among
X these are:
X
X SunOS 4.1 / Sun Sparcstation 1 (using both 'cc' and 'gcc 1.37.1')
X SunOS 4.0.3 / Sun 3
X BSD 4.3 / VAX 8650
X SEIUX / Sumitomo Electric Ustation/S
X Sony NEWS-OS 3.3 / Sony NEWS (fairly vanilla 4.3BSD)
X System V.? / Hitachi 2050
X System V.? / NEC EWS 4800
X UNIOS-B / Omron Luna
X Dynix / Sequent Balance ('cc' for Natl. Semi. base + 'gcc 1.36')
X Unicos / Cray 2
X
X We (the authors) feel this program is obfuscated for the
X following reasons:
X
X (0) This is one of the few programs you'll see WHOSE VERY UTILITY
X DEPENDS ON ITS OBFUSCATION!
X
X (1) The contest entry may be used to send its wonderful self to
X anyone in the Unix world! Virus writers need not apply...
X
X (2) The basic idea is twisted enough to be patentable, but is,
X out of the kindness of our hearts (as well as to maintain
X eligibility for the large IOCCC prize fund), dedicated to
X the public domain. Claude Shannon, meet Alan Turing.
X
X (3) Meta-obfuscation is via obfuscated description (see ABSTRACT).
X
X (4) "Literary" allusion. Production code contains a reference to
X self-reference, preserved at amazing cost for sheer perversity.
X
X (5) Many, many micro obfuscations below, honed over three years
X time, in shell as well as C. Ask about the 'tar' pit escape,
X the argv[0] flip, Paul's &4294967295 portability hack, the
X "void where prohibited by flaw" fix, the scanf() spacesaver,
X shift shenanigans, signal madness, exit()ing stage left, and
X source-to-source transformations galore.
X
X For extra credit:
X
X Construct 'sharkmail', to auto-split sharkives into mailable
X segments and mail them. Here's a simple one, which could be
X extended to enable auto-reassembly with one shell cmd at the
X far end.
X
X ------------------------ cut here for sharkmail -----------------------
X #!/bin/sh
X m=$1; shift
X shark $* | split -800 - /tmp/shark$$
X n=`ls /tmp/shark$$* | wc -l | sed 's/ *//'`
X p=0
X for f in `ls /tmp/shark$$*`
X do
X p=`expr $p + 1`
X mail -s "bundle ($p of $n) from '`whoami`'" $m < $f
X done
X rm /tmp/shark$$*
X ------------------------ end of sharkmail -----------------------------
X
X
XShark history:
X
X May 1987: Karl Fox introduces 1023-byte zcat.c to USENET.
X It's too late for the 4th IOCCC.
X
X May 21, 1987: James A. Woods extends idea to construct self
X decompressing shar Trojan horse, utilizing 'cc', 'shar',
X 'zcat', & 'atob'; size: 2303 bytes.
X
X May 23, 1987: 'jaw' trims 250 bytes without much thought.
X
X June 2, 1987: 52 lines of shell, 1991 bytes, now made with 'tar',
X short-circuit C-compile at far end, dual-use main.c,
X portability mods. (jaw)
X
X Mar-May 1988: abortive run at 5th IOCCC.
X jaw.c - 1529 bytes. compile line: 152 bytes.
X generated funny code with execvp() to invoke shell.
X
X Aug 29, 1988: production version, now at 1830 bytes.
X
X Jan 1990: Paul Eggert does tour-de-force shark re-engineering.
X
X May 24, 1990: collaboration yields 999-byte jaw.c core (see above)
X and 1530-byte production shell code (w/comments).
X Eggert comes through with lion's share of improvements.
X 7th IOCCC code now faster than the atob/zcat it replaces.
X
X May 1990: 'jaw' develops experimental replacement using
X Dan Bernstein's high-compression 'squeeze'.
X
X
XTo which we add:
X
X June 1990: 'shark' wins the IOCCC, finally! :-)
SHAR_EOF
$TOUCH -am 0922163990 1990/jaw.hint &&
chmod 0444 1990/jaw.hint ||
echo "restore of 1990/jaw.hint failed"
set `wc -c 1990/jaw.hint`;Wc_c=$1
if test "$Wc_c" != "7401"; then
echo original size 7401, current size $Wc_c
fi
# ============= 1990/pjr.hint ==============
echo "x - extracting 1990/pjr.hint (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/pjr.hint &&
X
XMost Unusual Data Structure <pjr at pyra.co.uk> Peter J Ruczynski
X
X Peter J Ruczynski.
X Pyramid Technology Ltd.
X Pyramid House,
X Solatron Road
X Farnborough.
X Hants GU14 7PL
X England, U.K.
X
X
XJudges' comments:
X
X This program prints out a string. Can you figure out how
X it is done?
X
X By use of pointers to functions returning a struct of pointers
X to functions!
X
X Note that some compilers will be unable to compile the
X expression 'X=g()...' in main due to lack of temporary
X value space. One might want to try replacing main with:
X
X main(){X=s().v().o().o().l().S().d().l().i().o().w().N();}
X
X if this is a problem.
X
X
XSpoiler: (rot13 to read)
X
X Guvf cebtenz cevagf bhg gur fgevat:
X
X gur dhvpx oebja sbk whzcrq bire gur ynml qbt
X
X ol hfr bs cbvagref gb shapgvbaf ergheavat n fgehpg bs cbvagref
X gb shapgvbaf!
X
X
XSelected notes from the author: (rot13 to read)
X
X Vg vf fvzcyr gb znxr gur cebtenz cevag bgure fgevatf. Rnpu
X nycunorgvpny punenpgre sebz n gb m vf cevagrq bhg nf vgf
X bccbfvgr:
X
X n->m o->l p->k rgp
X
X Gb rapbqr n arj fgevat vachg gur fgevat nf vg vf zrnag gb pbzr bhg:
X
X K=f().i().b().b().y().F().q().y().v().b().j().A();
X
X Abgr: F() ercerfragf n fcnpr naq A() n arjyvar. Guvf jvyy abj
X cebqhpr...
X
X uryyb jbeyq
X
X By the way, there is actually a piece of code which is not used
X in the original program! I leave it as an intellectual exercise
X to the reader to find out what it is.
X
SHAR_EOF
$TOUCH -am 0922163990 1990/pjr.hint &&
chmod 0444 1990/pjr.hint ||
echo "restore of 1990/pjr.hint failed"
set `wc -c 1990/pjr.hint`;Wc_c=$1
if test "$Wc_c" != "1479"; then
echo original size 1479, current size $Wc_c
fi
# ============= 1990/scjones.hint ==============
echo "x - extracting 1990/scjones.hint (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/scjones.hint &&
XANSI Committee's Worst Abuse of C: <scjones at sdrc.uu.net> Larry Jones
X
X Larry Jones
X SDRC
X 2000 Eastman Dr
X Milford, OH 45150
X USA
X
X
XJudges' comments:
X
X The addition of trigraphs has made it easier to make programs
X hard to read. It was a dark and stormy night for C when the
X ANSI C committee added trigraphs to the standard. Too bad
X that they didn't just simply require a more reasonable ISO
X character set.
X
X The common.mk (non-ANSI) makefile uses sed to form scjones.alt.c.
X The scjones.alt.c is similar to the original scjones.c source,
X but with all the trigraphs converted. You might want to try:
X
X make -f common.mk scjones.alt.c
X
X even if you only have an ANSI compiler, just to see how
X the trigrapsh are converted.
X
XWARNING: In the future, we will be passing ANSI programs through a
X trigraph filter before reading. Trigraph-ifacation will
X not be a major consideration in future contests. People
X should exploit more interesting features of ANSI C.
X
X
XSelected notes from the author:
X
X Since this year's contest is dedicated to ANSI C, here is a
X strictly conforming entry. In accordance with the ANSI
X definition of a strictly conforming program it does not produce
X output dependent on any unspecified, undefined, or implementation
X defined behavior, and it does not exceed any of the minimum
X implementation limits. It adheres to all of the syntactic and
X semantic constraints of the standard, #includes the relevant
X headers for the functions it uses, and uses the EXIT_SUCCESS and
X EXIT_FAILURE macros to return a correct success/fail status to
X the invoking program. It also uses trigraphs for characters
X which are not in the Invariant Code Set of ISO 646:1983, so it
X will be portable to machines with deficient (from C's standpoint)
X character sets. In short, it should be very widely portable. As
X an extra added attraction, all of the lines are under 72
X characters long, which would allow for sequence numbers to be
X punched in columns 73-80 :-).
X
X [[ The Author sent us this note after he was informed that he won ]]
X
X Although I am quite grateful for the "ANSI Committee's Worst Abuse
X of C" title (were you aware that I am a member of the committee or
X is the double meaning unintentional?), I was really hoping for
X something more along the lines of "Closest Resemblance to Line Noise." :-)
X
X [[ ... it was unintentional ]]
SHAR_EOF
$TOUCH -am 0922163990 1990/scjones.hint &&
chmod 0444 1990/scjones.hint ||
echo "restore of 1990/scjones.hint failed"
set `wc -c 1990/scjones.hint`;Wc_c=$1
if test "$Wc_c" != "2466"; then
echo original size 2466, current size $Wc_c
fi
# ============= 1990/stig.hint ==============
echo "x - extracting 1990/stig.hint (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/stig.hint &&
XStrangest Abuse of the Rules: <stig at solan.unit.no> Stig Hemmer
X
X Stig Hemmer
X Norwegian Institute of Technology
X N-7034 Trondheim-NTH
X Norway
X
XJudges' comments:
X
X We changed the alias that the author's suggested alias from a
X C-shell alias to a Korn shell alias because many C-shells
X did not allow Stig Hemmer's form of aliasing. (The error
X may have also been due to some uucp site corrupting his
X entry) Below is the author's 'how to compile' sections as
X mailed to us:
X
X ---how to ANSI compile---
X Xecho alias c cc -E -o o.c shst.c -"\''Dc=main(){printf("\"N%sested E
X Ccomments allowed.\\n\",'/*/*/0*/**/'1?\"\":\"o n\"");}'\'';cc -o c o.c'
X Xsource shst.c"|csh
X ---how to common compile---
X Xecho alias c cc -E -o o.c shst.c -"\''Dc=main(){printf("\"N%sested E
X Ccomments allowed.\\n\",'/*/*/0*/**/'1?\"\":\"o n\"");}'\'';cc -o c o.c'
X Xsource shst.c"|csh
X
X Note that shst.c is renamed to stig.c in the distribution.
X
X Producing an equivalent C-shell alias or /bin/sh function
X is left as an exercise to the reader.
X
XWARNING: This program's 'how to compile' is too specific to a particular
X shell. The obfuscation of this program to more related to
X shell obfuscation than C obfuscation. This type of entry will
X not be permitted in future contests.
X
XSelected notes from the author:
X
X If you like shell programming you may also admire my
X creative quoting. (I use echo to create an alias
X which when run calls cc with the -D option to create a
X C macro with double quotes in it. ARRRRRGGGHHH!)
X
X The program is totally portable, but the compile
X commands are very shell specific so don't be TOO mad
X at me if they don't work for you.
X
X If you want to put these commands in a Makefile you
X must add 4 - four - backslashes at the end on first
X line. (At least that's what works here.)
X
X If everything works correctly it create an executable
X named c which checks whether your compiler supports
X nested comments. I've stolen the "/*/*/0*/**/1" from
X somewhere so don't give me any points for it. Of
X course neither ANSI nor K&R support nested comments
X when properly implemented, but what the heck.
SHAR_EOF
$TOUCH -am 0922163990 1990/stig.hint &&
chmod 0444 1990/stig.hint ||
echo "restore of 1990/stig.hint failed"
set `wc -c 1990/stig.hint`;Wc_c=$1
if test "$Wc_c" != "2213"; then
echo original size 2213, current size $Wc_c
fi
# ============= 1990/tbr.hint ==============
echo "x - extracting 1990/tbr.hint (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/tbr.hint &&
XBest Utility: <tbr at acm.princeton.edu, smd at att.research.com> Rakitzis & Dorward
X
X Byron Rakitzis Sean Dorward
X Princeton University Princeton University
X 5707 Old Lodge Dr. 10274 Burleigh Cottage Lane
X Houston, TX 77066 Ellicott City, MD 21043
X USA USA
X
XJudges' comments:
X
X This program implements a subject a well known Un*x utility whose
X original source was considered to be extremely obfuscated by many
X people, excluding its author. In fact, this utility one a major
X inspiration for the formation of this contest.
X
X The author supplied us with a slightly smaller unformatted version
X of the program which we include below:
X
X #define D ,close(
X char*c,q[512],m[256],*v[99],**u,*i[3];int f[2],p;main(){for(m[m[60]=m[62]=
X 32]=m[*m=124[m]=9]=6;e(-8),gets(1+(c=q))||exit(0);r(0,0))for(;*++c;);}
X r(t,o){*i=i[2]=0;for(u=v+98;m[*--c]^9;m[*c]&32?i[*c&2]=
X *u,u-v^98&&++u:3)if(!m[*c]){for(*++c=0;!m[*--c];);*--u=
X ++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[1]:1,(p=fork())?e(p),o?
X r(o,0)D o)D*f):4,wait(0):(o?dup2(*f,0)D*f)D o):*i?1 D
X 0),e(open(*i,0)):5,t?dup2(t,1)D t):i[2]?9 D
X 1),e(creat(i[2],438)):2,e(execvp(*u,u))):e(chdir(u[1])*2):6;}
X e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||exit(1):5;}
X
XSelected notes from the author: (rot13 to read)
X
X Guvf cebtenz vf n ehqvzragnel furyy. Vg qbrf v/b erqverpgvba, cvcrf
X naq pq. Vg syntf reebef ba snvyrq puqve'f, bcra'f, perng'f
X rkrpic'f, sbex'f naq n srj flagnk reebef.
X
X Guvf cebtenz vf boshfpngrq va n srj abgnoyr jnlf: ncneg sebz gur
X ynlbhg (na hasbeznggrq (ohg pehapurq) irefvba vf vapyhqrq sbe
X crbcyr jub jnag gb chg guvf guebhtu po) vg znxrf pyrire hfr bs n
X jevgr fgngrzrag, fb gung gur fnzr fgngrzrag pna or hfrq gb cevag
X reebef naq gur cebzcg. Ol pnyyvat gur reebe shapgvba jvgu gur inyhr
X -8, gur cbvagre bssfrg va gur rkcerffvba "?\a$ "-k/4 tbrf sebz 0 gb
X 2. Cerfgb! N cebzcg. Sbe reebef jvgu ahzoref fznyyre guna -4
X (v.r., HAVK flfgrz pnyyf) n dhrfgvba znex vf cevagrq.
X
X Gur reebe inyhr bs puqve vf qbhoyrq fb gung jr qba'g rkvg sebz gur
X cnerag furyy ba n puqve reebe (fvapr r() rkvgf ba -1 reebef bayl).
X Nyy bgure flfgrz pnyy snvyherf rkvg fvapr gurl ner sebz fhofuryyf.
X
X Erphefvba vf farnxvyl rzcyblrq gb nibvq n frpbaq pnyy gb sbex(),
X naq gur yvar vf cnefrq va n snveyl ovmneer snfuvba: onpxjneqf. Gur
X urneg bs gur cebtenz, gung vf, gur cneg juvpu cresbezf nyy sbexf,
X rkrpf, bcraf, rgp. vf BAR P FGNGRZRAG.
X
X Gur zrgn-inyhrf neenl vf vavgvnyvmrq va n ovmneer snfuvba, naq gur
X fhofrdhrag purpxf sbe gur '<' naq '>' ner cresbezrq va n fvatyr
X fgngrzrag hfvat n znfx, fvapr lbh xabj gung '>'&2 vf 0, jurernf
X '<'&2 vf 2. Bgure fhpu zvpeb-boshfpngvbaf nobhaq.
X
X Svanyyl, vg vf abgnoyr gung gur pbqr jnf unpxrq sbe zvavznyvgl. Vs
X lbh ybbx ng gur pbzcerffrq irefvba, lbh jvyy or uneq-cerffrq gb
X ryvzvangr zber guna n srj punenpgref (jr pna'g frr ubj gb znxr vg
X nal fznyyre!). 550 punenpgref vf cerggl yrna sbe n furyy gung qbrf
X guvf zhpu.
X
X OHTF
X
X Gur flagnk bs gur furyy unf abg orra shyyl rkcyberq, ohg vs lbh gel
X gb erqverpg va gur fnzr qverpgvba zber guna bapr, bayl bar
X erqverpgvba vf cresbezrq. Guvf vf n "srngher" bs gur jnl gur yvar
X vf cnefrq; n cbvagre gb gur fgnpx bs nethzragf vf nffvtarq naq na
X nethzrag vf fgbyra rirel gvzr n ">" be "<" vf rapbhagrerq. Gur
X furyy syntf na reebe vs ab nethzragf ner ba gur fgnpx. Guhf, sbe
X rknzcyr:
X png > sbb > one
X pngf gb sbb, fvapr vg jnf chfurq ynfg, ohg
X png > > sbb one
X pngf gb one, fvapr one jnf chfurq haqre sbb. (erzrzore jr'er
X cnefvat evtug-yrsg)
X
X Qrcraqvat ba lbhe synibe bs HA*K, pq jvgubhg na nethzrag jvyy
X rvgure cebqhpr na reebe be whfg qb abguvat.
X
X Gurer vf whfg bar reebe zrffntr, gur dhrfgvba znex, ohg url, gung'f
X nyy rq qbrf gbb.
SHAR_EOF
$TOUCH -am 0922163990 1990/tbr.hint &&
chmod 0444 1990/tbr.hint ||
echo "restore of 1990/tbr.hint failed"
set `wc -c 1990/tbr.hint`;Wc_c=$1
if test "$Wc_c" != "3890"; then
echo original size 3890, current size $Wc_c
fi
# ============= 1990/theorem.hint ==============
echo "x - extracting 1990/theorem.hint (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/theorem.hint &&
XBest of Show: <theorem at blake.u.washington.edu> Adrian Mariano
X
X Adrian Mariano
X University of Washington
X 2729 72nd Ave SE
X Mercer Island, WA 98040
X USA
X
X
XJudges' comments:
X
X The program's source implements four functions, all from the
X same source file!
X
X Usage:
X
X theorem expression x1 x2 h y1
X
X where:
X expression - function f(x,y) (see below)
X x1 - start of interval
X x2 - end of interval
X h - step size
X y1 - initial value (y(x1) == y1)
X
X When you compile theorem.c as is and run with 5 args, it numerically
X solves the equation y'=f(x,y), with a step size of h, over the interval
X x=[x1,x2], with the initial condition of y(x1)=y1.
X
X The 'expression' f(x,y), is any function of 'x' and 'y' with the
X operators:
X
X + - * / ^
X
X The symbol '^' is the power operator. Note that it only supports
X integer powers. Also note that all expressions are evaluated strictly
X left to right. (i.e., parenthesis aren't supported).
X
X Try running the program with the following args:
X
X theorem y 0 1 0.1 1
X theorem 1/x 1 2 0.1 0
X theorem 'x^2/y+x' 0 1 0.1 6
X
X But wait, there is more! You also get, free of charge, a
X reversing filter! Try:
X
X theorem -r 0 0 0 0 < theorem.c > sorter.c
X
X Still not impressed? The author throws in for free, a
X sort program! Try:
X
X cc sorter.c -o sorter
X ls | sorter
X
X This program is safe for home use as well. The author has
X included a safety feature in case you misplace the original
X program source:
X
X sorter -r 0 0 0 0 < sorter.c > theorem_bkp.c
X
X And finally, as a special offer to users of this entry,
X the author provides a Fibonacci sequence generator! Try:
X
X sorter 0 0 0 0 < theorem.c > fibonacci.c
X cc fibonacci.c -o fibonacci
X fibonacci 1 1
X fibonacci 2 1
X
X Program available 9 track and cartridge cassette. Gensu knife
X not included! :-)
X
X When this program was first shown at the 1990 Summer Usenix
X conference, it received a standing ovation; a first for
X a contest entry.
X
X It should be noted that the 4 trailing args '0 0 0 0', are
X required on systems that dump core when NULL is dereferenced.
X
X
XSelected notes from the author:
X
X Differential equations are solved via the Runge-Kutta method,
X which guarantees local error proportional to h^5, and total
X error across a finite interval is at most a constant times h^4.
X
X Sorting is accomplished with a standard shell sort.
X
X Note that the sorting and reversing is limited to files with
X fewer than 500 lines, each less than 99 characters long.
SHAR_EOF
$TOUCH -am 0922163990 1990/theorem.hint &&
chmod 0444 1990/theorem.hint ||
echo "restore of 1990/theorem.hint failed"
set `wc -c 1990/theorem.hint`;Wc_c=$1
if test "$Wc_c" != "2585"; then
echo original size 2585, current size $Wc_c
fi
# ============= 1990/westley.hint ==============
echo "x - extracting 1990/westley.hint (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/westley.hint &&
XBest Layout: <...uunet!rosevax!jhereg!quest!digibd!merlyn> Merlyn LeRoy
X
X Brian Westley (Merlyn LeRoy on usenet)
X DigiBoard, Inc.
X 1026 Blair Ave.
X St. Paul, MN 55104
X USA
X
XJudges' comments:
X
X usage: westley <number>
X
X If you would rather "Daisy" someone other than Westley, rename
X the program as needed. :-)
X
X Read each block of code as if it were a piece of correspondence.
X For example, the first block of code would read:
X
X charlie,
X doubletime me, OXFACE!
X not interested, get out
X mainly die, charly, *die*
X signed charlotte
X
X The original source had control-L's after each code block. To
X make it easier on news readers, we converted each control-L to
X a blank line.
X
X Some ANSI compilers will not accept '1s' as a short integer - for
X these compilers replace the '1s' with '1'.
X
X
XSelected notes from the author:
X
X This is a "Picking the Daisy" simulation. Now, instead of mangling a
X daisy, simply run this program with the number of petals desired as
X the argument.
X
X This is a good counter-example to peoples' complaints that C doesn't
X have an "English-like" syntax.
X
X Lint complains about everything - null effect, xxx may be used before
X set, statement not reached, return(e) and return. Lint dumps core
X on some systems. My personal favorite lint complaint is
X
X "warning: eroticism unused in function main".
X
X Also obviously, (char)lotte and (char*)lie are incompatible types...
SHAR_EOF
$TOUCH -am 0922163990 1990/westley.hint &&
chmod 0444 1990/westley.hint ||
echo "restore of 1990/westley.hint failed"
set `wc -c 1990/westley.hint`;Wc_c=$1
if test "$Wc_c" != "1489"; then
echo original size 1489, current size $Wc_c
fi
# ============= 1990/LANDER.BAS ==============
echo "x - extracting 1990/LANDER.BAS (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/LANDER.BAS &&
X10 REM Lunar Lander
X20 REM By Diomidis Spinellis
X30 PRINT "You aboard the Lunar Lander about to leave the spacecraft."
X60 GOSUB 4000
X70 GOSUB 1000
X80 GOSUB 2000
X90 GOSUB 3000
X100 H = H - V
X110 V = ((V + G) * 10 - U * 2) / 10
X120 F = F - U
X130 IF H > 0 THEN 80
X135 H = 0
X140 GOSUB 2000
X150 IF V > 5 THEN 200
X160 PRINT "Congratulations! This was a very good landing."
X170 GOSUB 5000
X180 GOTO 10
X200 PRINT "You have crashed."
X210 GOTO 170
X1000 REM Initialise
X1010 V = 70
X1020 F = 500
X1030 H = 1000
X1040 G = 2
X1050 RETURN
X2000 REM Print values
X2010 PRINT " Meter readings"
X2015 PRINT " --------------"
X2020 PRINT "Fuel (gal):"
X2030 PRINT F
X2040 GOSUB 2100 + 100 * (H <> 0)
X2050 PRINT V
X2060 PRINT "Height (m):"
X2070 PRINT H
X2080 RETURN
X2100 PRINT "Landing velocity (m/sec):"
X2110 RETURN
X2200 PRINT "Velocity (m/sec):"
X2210 RETURN
X3000 REM User input
X3005 IF F = 0 THEN 3070
X3010 PRINT "How much fuel will you use?"
X3020 INPUT U
X3025 IF U < 0 THEN 3090
X3030 IF U <= F THEN 3060
X3040 PRINT "Sorry, you have not got that much fuel!"
X3050 GOTO 3010
X3060 RETURN
X3070 U = 0
X3080 RETURN
X3090 PRINT "No cheating please! Fuel must be >= 0."
X3100 GOTO 3010
X4000 REM Detachment
X4005 PRINT "Ready for detachment"
X4007 PRINT "-- COUNTDOWN --"
X4010 FOR I = 1 TO 11
X4020 PRINT 11 - I
X4025 GOSUB 4500
X4030 NEXT I
X4035 PRINT "You have left the spacecraft."
X4037 PRINT "Try to land with velocity less than 5 m/sec."
X4040 RETURN
X4500 REM Delay
X4510 FOR J = 1 TO 500
X4520 NEXT J
X4530 RETURN
X5000 PRINT "Do you want to play again? (0 = no, 1 = yes)"
X5010 INPUT Y
X5020 IF Y = 0 THEN 5040
X5030 RETURN
X5040 PRINT "Have a nice day."
SHAR_EOF
$TOUCH -am 0922163990 1990/LANDER.BAS &&
chmod 0444 1990/LANDER.BAS ||
echo "restore of 1990/LANDER.BAS failed"
set `wc -c 1990/LANDER.BAS`;Wc_c=$1
if test "$Wc_c" != "1624"; then
echo original size 1624, current size $Wc_c
fi
# ============= 1990/stig.ksh ==============
echo "x - extracting 1990/stig.ksh (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/stig.ksh &&
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"
SHAR_EOF
$TOUCH -am 0922163990 1990/stig.ksh &&
chmod 0444 1990/stig.ksh ||
echo "restore of 1990/stig.ksh failed"
set `wc -c 1990/stig.ksh`;Wc_c=$1
if test "$Wc_c" != "136"; then
echo original size 136, current size $Wc_c
fi
# ============= 1990/shark.sh ==============
echo "x - extracting 1990/shark.sh (Text)"
sed 's/^X//' << 'SHAR_EOF' > 1990/shark.sh &&
Xfor i in "${@?${usage?$0 file...}}";do<"$i"||exit;done
X(cat&&tar cbf 1 - "$@"|compress|btoa&&echo w)<<\Z
X#!/bin/sh
X#
X# GENTLE READER -- write this message to file [no headers!]; run "sh file".
X#
X# [un]shark: By James A. Woods.
X# Seed planted by Karl Fox; code intensified by Paul Eggert.
X#
X# "Cleverly he dialed from within." -- D. Van Vliet, "Trout Mask Replica"
X#
XPATH=$PATH:. a=atob m=unshark z=zcat
Xr="rm -f $a $m* $z" v="cc -o $z $m.c"
Xtrap "$r;exit 1" 1 2 13 15
Xecho decoding...
X(:|compress|btoa|$a|$z)2>$m>&2||(sed '1,9s/./#define & /
Xs/@/[w]/g
Xs/C/char /g
Xs/I/;if(/g
Xs/W/;while(/g
Xs/Y/%lx /g
Xs/}/;}/g'>$m.c<<_&&
XFX,perror("$m bite: resend"),1;
XGgetC()
XH(w=g())
XK[69001]
XPputC
XQ256
XU*p
XXreturn 0
XZw=QWw--)t@=0
X#include<stdio.h>
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
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
XK;main(g,V)C**V;{I**V-97)X,a()WG-10)W(g=G)+1&&g-'x')if(g-10)
X{I4<k)b(0)Ig>32&g<'v')w=w*85+g-33,++k;else{Ig-'z'|k)F
Xw=0;k=5}}WG-78)Iscanf("%ldYEYSYRY",&M,&N,&c,&s,&r)-5)F
XIM){b(g=3-(M-1&3))Wg--)y(0)}I(M-N|c-o|s-m|r-f)&4294967295)F X}long
Xg(){CUIm<f&n<k&&(m=(1l<<++n)-1)||O>=S){O=0;S=fread(D,1,n,stdin)*8IS<8)X-1;
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}
Xa(){CU=D+Q;G;G;k=G;e=k>>7&1;k&=31Ik>16)F
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}
Xc=wIw>=f)U++=i,w=oWw>=Q)U++=h@,w=t@;P(i=h@)Wp>D+Q)P(*--p)
XI(w=f)<1l<<k)t@=o,h[f++]=i;o=c}X}
X_
X($v||$v -Mh)&&ln $z $a)&&$a<<\w>$m-&&$z<$m->$m&&tar xvf $m&&$r
XZ
SHAR_EOF
$TOUCH -am 0922163990 1990/shark.sh &&
chmod 0444 1990/shark.sh ||
echo "restore of 1990/shark.sh failed"
set `wc -c 1990/shark.sh`;Wc_c=$1
if test "$Wc_c" != "1522"; then
echo original size 1522, current size $Wc_c
fi
exit 0
--
For a good prime, call: 391581 * 2^216193 - 1
More information about the Comp.lang.c
mailing list