home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1991-08-28 | 59.2 KB | 1,656 lines
Xref: wupost comp.lang.c:26413 comp.sources.d:3892 comp.unix.wizards:3350 alt.sources:3923 misc.misc:8113 Path: wupost!uunet!hoptoad!chongo From: chongo@hoptoad.uucp (Landon C. Noll) Newsgroups: comp.lang.c,comp.sources.d,comp.unix.wizards,alt.sources,misc.misc Subject: 1991 International Obfuscated C Code Contest winners, 2 of 2 Message-ID: <20429@hoptoad.uucp> Date: 28 Aug 91 01:42:01 GMT Expires: 28 Nov 91 00:00:00 GMT Reply-To: chongo@hoptoad.UUCP (Landon C. Noll) Distribution: world Organization: Nebula Consultants in San Francisco Lines: 1641 Keywords: ioccc Enclosed is part 2 of a 2 part shar file containing the winners of the 1991 International Obfuscated C Code Contest. First, we congratulate the winners for doing a fine job. Their efforts and feedback have resulted in a number of suggested changes for the 1992 contest. Second, we will be posting, sometime in early October 1991, a proposed set of rules for the 1992 contest. At that time, we will be requesting feedback on the proposed 1992 rules. Sometime later, perhaps in early November 1991, the official 1992 IOCCC rules will be posted. Last, we would like to make an apology to the 1991 winners and to the net for the delay in posting of these results. The poster of this article (chongo) went on vacation (Eclipse watching in Hawaii), held extended discussions with several of the contest winners, attempted to formulate the 1992 rules, and just plain ran out of time. We hope to avoid such delays in the future. If you find problems with some of the contest entries, or find typos in our notes, please send PATCH FILES containing the corrections to: judges@toad.com -or- ...!{sun,uunet,utzoo,pyramid}!hoptoad!judges chongo <Landon Curt Noll> /\cc/\ hoptoad!chongo Larry Bassel {uunet,ucbvax,cbosgd}|sun!lab p.s. previous winners are available on uunet.uu.net via anonymous ftp under the directory ~/pub/ioccc. The updated and corrected 1991 set will be deposited there when the 1992 rules are posted. Submitted-by: chongo@toad.com (Landon Curt Noll) # # Send comments, questions, bugs to: # # judges@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 # deadline date for the contest is late May. Check with the current year's # rules for details. # # 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, you may request a copy from the judges, via Email, # from the address above. # # The 1992 contest rules will differ from the 1991 contest in several # important ways. Due to these changes, there will be a delay in # the posting of the 1992 rules. We expect the 1992 rules to be ready # by early October 1991. # Archive-name: ioccc.1991/part02 ---- Cut Here and unpack ---- #!/bin/sh # This is part 02 of ioccc.1991 if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= 1991/sorta.idup ============== echo "x - extracting 1991/sorta.idup (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.idup && X[ld#1_+1=y]:x X[uD1+=x]:y X0""1=y` SHAR_EOF $TOUCH -am 0622130991 1991/sorta.idup && chmod 0444 1991/sorta.idup || echo "restore of 1991/sorta.idup failed" set `wc -c 1991/sorta.idup`;Wc_c=$1 if test "$Wc_c" != "33"; then echo original size 33, current size $Wc_c fi # ============= 1991/sorta.iecho ============== echo "x - extracting 1991/sorta.iecho (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.iecho && X[" "$ld]:sld [ print a space ]ld X[1s1+DA$ld1s1_+D=sD=x]:xld [ given n (argc-n), print args ]ld X0a1_+D=x""` [ simulation of /bin/echo ]ld SHAR_EOF $TOUCH -am 0622130991 1991/sorta.iecho && chmod 0444 1991/sorta.iecho || echo "restore of 1991/sorta.iecho failed" set `wc -c 1991/sorta.iecho`;Wc_c=$1 if test "$Wc_c" != "181"; then echo original size 181, current size $Wc_c fi # ============= 1991/brnstnd_ansi.c ============== echo "x - extracting 1991/brnstnd_ansi.c (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/brnstnd_ansi.c && X#include <stdio.h> X#define H(x,y,z) f(p){--p;c=x-_+1];f(c>0){y+1]=z[c];z[c]=y];y]=y+1];}} X#define O(x,y) F(x,int U;int T=0;d=M(U=1);W{f(c==y)b g[T++]=c;f(T==U)g=realloc(g,U<<=1);}g[T]=0;) X#define W Y((c=k?K[--k]:getchar())-EOF) X#define S i[q X#define F(w,z) f(c==w){z h} X#define f if X#define P p>1&&(c=u, X#define _ s[p X#define C =G X#define g S] X#define J(x,y) F(I[x],y) X#define Q P e X#define Y while X#define b break; X#define u _--] X#define m p&& X#define R char* X#define l Z[c] X#define L strlen X#define d i[++q] X#define G c) X#define h ;continue; X#define N s[++p] X#define e _] X#define j x;{R r=M(L( X#define v return X#define w [256] X#define V f(k>o||p>o||q>o)v 2; XR I="I'd love ta win: the most useful !$>%`/#<&*|^ _OBFUSCATED_ utility. Pleez?";U(y,x)R y;R*j*x)+L(y)+1);sprintf(r,"%s%s",*x,y);*x=r;}R T(x)R j x)+1);strcpy(r,x);v Xr;}R(i w);static R(Z w);int K w;main(a,A)int a;R*A;{int s w,p=0,q=0,n=0,c,k=0;W{V Xf(c>='0'&&c<='9'){f(!n)N=0;n=1;e=10*e+(c-'0')h}n=0;J(39,m Xsprintf(d=M(13),"%d",e)) XJ(37,q&&puts(g))J(34,q&&printf("%s",g))J(27,H(p,_,s))O('[',']')J(56,f(p){c=e;N=c;})J(2,m--p)J(10,N=a)J(4,f(q){N=L(g);X(S--]);})J(1,f(q){S+1]=T(g);++q;})J(53,m Xe>=0&&e<a&&(d=T(A[u]))) XJ(54,q>1&&(--q,U(S+1],i+q)))J(5,q&&p>1&&(_-1]=open(g,_-1],e),--p,X(S--])))J(47,m Xclose(u)) XJ(26,m(e=dup(e)))O('"','"')J(51,H(q,S,i))J(49,N=fork())J(12,wait(&N)+1||(e=-1))J(68,{++p;pipe(s+p++)==-1&&(e=-1);})F('q',v X0) XF('=',W{R x;f(m u)f(x=l){k+=n=L(x);V;Y(*x)K[--k]=*x++;k+=n;n=0;}b})J(15,f(q)W{l&&X(l);l=T(g);b})J(33,f(c=q){*i=g;g=0;Y(--q&&**(i+q))g++;f(q){N=execvp(*i,i+q+1);q=c;}})J(38,P Xc&&(e/C)) XJ(35,Q=e>G)F('+',Q+C)J(42,Q*C)J(41,Q=~(e&G))J(57,m(e=-e))J(3,)F('\n',)putchar(c);puts(73+I);}} SHAR_EOF $TOUCH -am 0807171891 1991/brnstnd_ansi.c && chmod 0444 1991/brnstnd_ansi.c || echo "restore of 1991/brnstnd_ansi.c failed" set `wc -c 1991/brnstnd_ansi.c`;Wc_c=$1 if test "$Wc_c" != "1669"; then echo original size 1669, current size $Wc_c fi # ============= 1991/cdupont_ansi.c ============== echo "x - extracting 1991/cdupont_ansi.c (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/cdupont_ansi.c && X /* common sense to nohonest programmer */ X#include <stdio.h> Xmain(){int x ,gi=4,i,f,ri=1,httxkbl=1,m=012;long cd=0x5765248d,n; X char u[0x50][032];FILE *ind; X ind=fopen(s,t); for(i=0; i<0x1a; i++){goto daswjhkls;vhjsgfdy1l1gjhd:;} X/*borntorun.*/goto c0g0;cOgO:i=0;fclose(ind);c0gO: Xx= u [gi][m]; sorryfor_this_unused_but_very_needed_label: X if( m==gi){x=0x70;f=0x68;}else goto cOg0 ; b:putchar(x); if( X!(n-httxkbl++)) X#define yank(x) putchar(x) X {httxkbl=1; yank(' ');goto X hxi;}goto bl; X /* hardlyundrstandable, but Xlikely to be missed if removed */ X daswjhkls: fgets(u[i], 0120, ind); X /*obfuscated, eh? */goto X vhjsgfdy1l1gjhd; X c0g0 : n=cd&0x40000000L>>0x1e; X goto cOgO; g6w: X if(x!=0x2e){i++;goto c0gO;}else /* Xinjail*/yank('\n');goto vhjsgfdyl1lgjhd; XcOg0 : Xf=u[m][gi];goto b;bl:m=(i+1)*(4* Xx+3*f)%032;gi=(i+1)*(x+2*f)%0x1a; goto g6w; X hxi:cd^= n= cd&(7<<3*(014-++ri)); Xn >>=3*(12-ri); goto bl;vhjsgfdyl1lgjhd:;} SHAR_EOF $TOUCH -am 0527202891 1991/cdupont_ansi.c && chmod 0444 1991/cdupont_ansi.c || echo "restore of 1991/cdupont_ansi.c failed" set `wc -c 1991/cdupont_ansi.c`;Wc_c=$1 if test "$Wc_c" != "1009"; then echo original size 1009, current size $Wc_c fi # ============= 1991/ttt.sh ============== echo "x - extracting 1991/ttt.sh (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/ttt.sh && X#!/bin/sh X# X# play tic-tac-toe X X# parse args X# Xif [ $# -gt 1 ]; then X echo "usage: ttt [move_digit]" 1>&2 X echo " ttt quitgame" 1>&2 X echo " ttt clobber" 1>&2 X exit 1 Xelif [ $# -eq 1 ]; then X move="$1" Xelse X move= Xfi X X# catch the clobber case X# Xif [ clobber = "$move" ]; then X echo "ttt: rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c" 1>&2 X rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c X echo "ttt: rm -f merlyn.c merlyn.o merlyn" 1>&2 X rm -f merlyn.c merlyn.o merlyn X echo "ttt: removed all but the original source" 1>&2 X exit 0 Xfi X X# catch the quitgame case X# Xif [ quitgame = "$move" ]; then X echo "ttt: rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c" 1>&2 X rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c X echo "ttt: current game removed, perhaps you were going to lose? :-)" 1>&2 X exit 0 Xfi X X# watch for bad args X# Xif [ $# -eq 1 ]; then X case "$move" in X 1|2|3|4|5|6|7|8|9) ;; X *) echo "ttt: bad argument" 1>&2 X echo "usage: ttt [move_digit]" 1>&2 X echo " ttt quitgame" 1>&2 X echo " ttt clobber" 1>&2 X exit 2 ;; X esac Xfi X X# be sure that we have the merlyn.c source X# Xif [ ! -f merlyn.c ]; then X if [ -f westley.c ]; then X echo "ttt: No merlyn.c around these parts, using a copy of westley.c" 1>&2 X cp westley.c merlyn.c X chmod +w merlyn.c X else X echo "ttt: Ouch! merlyn.c and no westley.c are gone!" 1>&2 X exit 3 X fi X # check to see if the copy worked X if [ ! -f merlyn.c ]; then X echo "ttt: Darn, coundn't copy westley.c to merlyn.c" 1>&2 X exit 4 X fi Xfi X X# be sure we have the merlyn program X# Xif [ ! -f merlyn ]; then X echo "ttt: make merlyn" 1>&2 X make merlyn X status=$? X if [ "$status" -ne 0 ]; then X echo "ttt: something is wrong, fix merlyn.c and build it yourself!" 1>&2 X echo " or maybe type: ttt clobber" 1>&2 X exit 5 X fi X rm -f ttt_game.c Xfi X X# If we don't have a ttt_game.c, or we cannot write it, make a new ttt_game.c X# Xif [ ! -w ttt_game.c ]; then X rm -f ttt_game.c X if [ -z "$move" ]; then X merlyn | tee ttt_game.c X else X merlyn "$move" | tee ttt_game.c X fi X chmod +w ttt_game.c X X# If we have a ttt_game.c, then assume that we are in the process of playing X# Xelse X rm -f ttt_game ttt_new.c X echo "ttt: make ttt_game" 1>&2 X make ttt_game X status=$? X if [ "$status" -ne 0 ]; then X echo "ttt: something is wrong, fix ttt_game.c and build it yourself!" 1>&2 X echo " or maybe type: ttt quitgame" 1>&2 X exit 6 X fi X if [ -z "$move" ]; then X ttt_game | tee ttt_new.c X else X ttt_game "$move" | tee ttt_new.c X fi X chmod +w ttt_new.c X if [ -s ttt_new.c ]; then X mv ttt_game.c ttt_old.c X mv ttt_new.c ttt_game.c X X# Check for win, lose, or draw X# For a win or draw, copy merlyn.c to ttt_game.c X# For a loss, copy ttt_game.c to merlyn.c, as it is now better X# Also remove the executable for the file replaced X# For anything else, game in progress, do not do anything X X if [ -n "`grep ':-(' ttt_game.c`" ]; then X echo X echo "ttt: I lose...I won't make THAT mistake again!" X chmod +w merlyn.c X mv ttt_game.c merlyn.c X rm -f merlyn ttt_game X else X if [ -n "`grep ':-)' ttt_game.c`" ]; then X echo X echo "ttt: I win!" X cp merlyn.c ttt_game.c X rm -f ttt_game X else X if [ -z "`grep 'X=-. ' ttt_game.c`" -a -z "`grep '^. ' ttt_game.c`" ]; then X echo X echo "ttt: It's a draw - play again?" X cp merlyn.c ttt_game.c X rm -f ttt_game X fi X fi X fi X X else X echo "ttt: something is wrong, maybe ttt_old.c will help" 1>&2 X echo " or maybe type: ttt quitgame" 1>&2 X echo " or maybe type: ttt clobber" 1>&2 X exit 7 X fi Xfi X SHAR_EOF $TOUCH -am 0814033991 1991/ttt.sh && chmod 0444 1991/ttt.sh || echo "restore of 1991/ttt.sh failed" set `wc -c 1991/ttt.sh`;Wc_c=$1 if test "$Wc_c" != "3704"; then echo original size 3704, current size $Wc_c fi # ============= 1991/westley.hint ============== echo "x - extracting 1991/westley.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/westley.hint && XGrand Prize: <merlyn@digibd.com> Brian Westley X X Brian Westley (Merlyn LeRoy on usenet) X DigiBoard, Inc. X 1026 Blair Ave. X St. Paul, MN 55104 USA X X XJudges' comments: X X Make and run as follows: X X make westley X westley [move_location] | tee nextmove.c X X where the 'move_location' is a digit from 1 to 9 that represents X a move on a tic-tac-toe board: X X 1 2 3 X 4 5 6 X 7 8 9 X X If you omit 'move_location', then the computer moves first. For your X next move, recompile nextmove.c and play it again: X X make nextmove X nextmove move_location | tee nextmove.c X X We have provided the shell script, ttt, to make it easier to play the game: X X make ttt X ttt [first_move] <- omit first arg to have it move first X ttt next_move X X The shell script determines when the game is over, and automatically X replaces merlyn.c with an improved version after a loss. The ttt script X has two other modes: X X ttt quitgame <- cancel any game in process, revert to merlyn.c X ttt clobber <- remove all game files, revert to original source X X Try not to cheat, the computer has not learned how to catch you doing it. X X XSelected notes from the author: X X A tic-tac-toe self-modifying program that "learns". This C program X plays standard tic-tac-toe on itself. The code is written as a X tic-tac-toe grid; moves are carried out within the code. X X The human is X, the computer 0 [sic, "zero", not letter "O"]. X X The program, when run, reproduces itself with both the player's X move and the computer's move added. Recompile THIS program (using X the same compile line) and repeat until the game is finished. X X If the computer wins, the "straight face" in the upper right-hand X corner ":-|" will change into a happy face ":-)". If it is a draw, X the face does not change. If the computer loses, the board is X blanked and the face changes into a sad face ":-(". If this X happens, the blank board should replace the original program; the X computer changes its play and will continue to do so until it no X longer loses games. X X If you want a program that never loses, simply replace the string X "9999999999 :-| " with "9883857753 :-| ". X X How It Works (rot13 to read) X ---------------------------- X X Gur iregvpny "onef" bs gur tevq ner vqragvpny shapgvbaf, jvgu gur X anzr bs gur shapgvba nf n(), o(), be p(). Nsgre rnpu shapgvba vf X pnyyrq, gur tybony inevnoyrf K naq B pbagnva ovgznfxf bs jurer nyy X gur Kf naq Bf ner cynprq. Gur fgngrzrag: X X K=- <pune> -1; X X rinyhngrf gb 1, -1, be -2 jura K vf 1 naq <pune> vf bar bs "K", X "0", be " ". Gur shapgvba F(&K) frgf gur nccebcevngr ovgf va X (tybony ine) K naq B naq erfrgf gur inyhr bs &K gb 1. Guvf vf ubj X gur pheerag cbfvgvba vf pbzchgrq. X X Gur cynlre'f zbir vf BE'q vagb gur K znfx, naq (vs vg vf gur X bcravat zbir) gur fgengrtl fgevat'f svefg punenpgre vf frg gb gur X cynlre'f svefg zbir (be "5" vs gur pbzchgre zbirf svefg). X X Gur rinyhgvba shapgvba l(Z) purpxf vs gur znfx unf n jvaavat X cnggrea (nal bs gur svefg rvtug ovgznfxf bs gur j[] neenl), naq X frgf gur inevnoyr d gb 0 vs vg qbrf. X X Gur cynlre'f zbir vf rinyhngrq gb frr vs gur uhzna unf jba. Gur X fzvyrl vf frg gb :-) be :-( qrcraqvat ba guvf. Nyfb, vs gur uhzna X unf jba, gur qvtvg va gur fgengrtl fgevat vf qrperzragrq gb punatr X gur pbzchgre'f cynl sbe arkg tnzr. X X Vs gur uhzna unf ABG jba, gur r(A,Z) shapgvba rinyhngrf vs NAL zbir X abg va znfx A pna cebqhpr n jva va znfx Z. Gur svefg rinyhngvba X r(K,B) purpxf vs B pna znxr n yrtny jvaavat zbir. Vs fb, gur X pbzchgre unf n jvaavat zbir naq znxrf vg. Vs abg, gur fzvyrl vf X frg gb :-|, naq n aba-jvaavat zbir vf trarengrq. X X N aba-jvaavat zbir svefg purpxf vs K pna jva va bar zbir; vs fb, X guvf zbir vf fryrpgrq, oybpxvat gur jva. Bgurejvfr, n zbir vf X trarengrq ol ybbxvat qbja gur yvfg bs "zbir grzcyngrf". Gur svefg X zbir grzcyngr gung trarengrf n zbir gung vf ABG nyernql bpphcvrq ol X na K be B vf erghearq. X X Gur "zbir grzcyngrf" ner fgngvp gvp-gnp-gbr cbfvgvbaf gung trarengr X cbffvoyr zbirf ol znxvat gur r() shapgvba erghea "jvaavat" zbirf, X r.t. gur grzcyngr: X X . . . X B , B (guvf vf gur inyhr 40; 2^3+2^5) X . . . ("B"f ner 1 ovgf, "." naq "," ner 0 ovgf) X X ...jvyy znxr gur r() shapgvba erghea n pragre zbir, nf X guvf vf gur bayl zbir gung cebqhprf guerr va n ebj. Abgvpr gung X gur pbzchgre qbrf abg pbafvqre juvpu pryyf pbagnva Kf naq Bf jura X znxvat n grzcyngr zbir, bayl juvpu pryyf ner rzcgl naq abg-rzcgl. X Guvf znxrf sbe hahfhny cynl. X X Gur grzcyngrf ner pnershyyl pubfra gb riraghnyyl oybpx nyy gencf X gung K pna gel, ol whfg oyhaqrevat va gur jnl. X X Nyfb abgr gung gur jvaavat & fgengrtl grzcyngrf ner cneg bs gur X pbzcvyr yvar, znxvat vg cbffvoyr gb punatr gur ehyrf bs gur tnzr ol X punatvat gur pbzcvyr yvar. X X Gur grzcyngrf ner: X X B , B X , , , X B , B X X , . . X . B . X . . B X X . . . X B , B X . . . X X . . . X B B , X . . . X X . . . X B , B X . . . X X . , , X . B . X B B , X X B , B X , , . X B . . X X , . B X B , B X B . , X X B . , X B , B X , . B X X B , B X , , , X B , B X X N qvtvg bs "9" zrnaf fgneg jvgu gur svefg grzcyngr, "8" fgnegf ng X gur frpbaq, rgp. Gur grzcyngrf ner fpnaarq hagvy n yrtny zbir vf X sbhaq. N grzcyngr vf fpnaarq sebz obggbz gb gbc, evtug gb yrsg X (v.r. zbir 9 vf grfgrq svefg, gura 8, qbja gb zbir 1). SHAR_EOF $TOUCH -am 0815181991 1991/westley.hint && chmod 0444 1991/westley.hint || echo "restore of 1991/westley.hint failed" set `wc -c 1991/westley.hint`;Wc_c=$1 if test "$Wc_c" != "5435"; then echo original size 5435, current size $Wc_c fi # ============= 1991/dds.hint ============== echo "x - extracting 1991/dds.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/dds.hint && XMost Well Rounded: <dds@doc.ic.ac.uk> Diomidis Spinellis X X Diomidis Spinellis X Imperial College, University of London X Myrsinis 1 X GR-145 62 Kifissia X Greece X X XJudges' comments: X X Make and run as follows: X X make dds X dds basic_program X a.out X X For example, the author suggests trying: X X dds LANDER.BAS X a.out X X Notice that a file a.c has been generated. Can you tell how a.c was X produced? How does a.c relate to LANDER.BAS? X X This obfuscated program translates BASIC programs into obfuscated X C programs by way of an obfuscated algorithm. X X NOTE: Due to minor problems with some strict ANSI C compilers, we X have supplied a more portable ANSI version. X X XSelected notes from the author: X X This program is a companion to the DDS-BASIC interpreter program that X was submitted to the contest in 1990. This compiles BASIC programs into X executable commands. The input format is almost identical to the input X format of the DDS-BASIC interpreter. The program needs an executable C X compiler called `cc' in your path in order to work. X X Program commands: X X variable names A to Z variables initialized to 0 on RUN X FOR var = exp TO exp NEXT variable X GOSUB exp RETURN X GOTO exp IF exp THEN exp X INPUT variable PRINT string X PRINT exp var = exp X REM any text END X X Expressions are the same as the expressions of the C language. X Many system calls and C library calls can be used. X X Input format: X X - Free format positioning of tokens on the line. X - No space is allowed before the line number. X - Exactly one space is needed after the FOR and NEXT tokens X - ALL INPUT MUST BE UPPERCASE. X X Error checking / error reports: X X The compiler silently ignores many errors. X Other errors may produce errors in later phases of the compilation. X XCan you figure out how the compiler works? Hint (rot13): X X The compiler is NOT written in C, so this is really a meta-obfuscated X program. The C code is an intepreter for the four register, seven X instruction COGNIMP$ machine that is contained in the s string. X (COGNIMP$ is named after the symbolic names of the seven instructions it X defines (Print Output Goto Match If, iNcrement and Copy). The $ sign X is used for labels.) The actual compiler is written in COGNIMP$. X Browsing through the COGNIMP$ code we encouriage you to examine the X loops for scanning the expression in the IF statement and the way a X decision tree is implemented in order to match the statements. (Of X course the 's' string is encoded by adding one to every character of it just X to confuse you). SHAR_EOF $TOUCH -am 0814003291 1991/dds.hint && chmod 0444 1991/dds.hint || echo "restore of 1991/dds.hint failed" set `wc -c 1991/dds.hint`;Wc_c=$1 if test "$Wc_c" != "2619"; then echo original size 2619, current size $Wc_c fi # ============= 1991/LANDER.BAS ============== echo "x - extracting 1991/LANDER.BAS (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/LANDER.BAS && X10 REM Lunar Lander X20 REM By Diomidis Spinellis X25 REM Compiler version 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 LET H = H - V X110 LET V = ((V + G) * 10 - U * 2) / 10 X120 LET F = F - U X130 IF H > 0 THEN 80 X135 LET 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 LET V = 70 X1020 LET F = 500 X1030 LET H = 1000 X1040 LET 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!" X3045 PRINT F X3050 GOTO 3010 X3060 RETURN X3070 LET 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." X5050 END SHAR_EOF $TOUCH -am 0527203391 1991/LANDER.BAS && chmod 0444 1991/LANDER.BAS || echo "restore of 1991/LANDER.BAS failed" set `wc -c 1991/LANDER.BAS`;Wc_c=$1 if test "$Wc_c" != "1708"; then echo original size 1708, current size $Wc_c fi # ============= 1991/sorta.ifact1 ============== echo "x - extracting 1991/sorta.ifact1 (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.ifact1 && X1#`ld2*#`ld3*#`ld4*#`ld5*#`ld6*#`ld7*#`ld8*#`ld9*#`ld10*#`ld SHAR_EOF $TOUCH -am 0622130991 1991/sorta.ifact1 && chmod 0444 1991/sorta.ifact1 || echo "restore of 1991/sorta.ifact1 failed" set `wc -c 1991/sorta.ifact1`;Wc_c=$1 if test "$Wc_c" != "61"; then echo original size 61, current size $Wc_c fi # ============= 1991/sorta.iio ============== echo "x - extracting 1991/sorta.iio (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.iio && X [ a simple example of interpreting code on the fly ]ld X X["] "2 2+":xT ["]T " produces "T 1=x#T " which should be 4."T` SHAR_EOF $TOUCH -am 0622131091 1991/sorta.iio && chmod 0444 1991/sorta.iio || echo "restore of 1991/sorta.iio failed" set `wc -c 1991/sorta.iio`;Wc_c=$1 if test "$Wc_c" != "125"; then echo original size 125, current size $Wc_c fi # ============= 1991/ant.hint ============== echo "x - extracting 1991/ant.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/ant.hint && XBest Utility: <ant@mks.com> Anthony C Howe X X Anthony C Howe X Mortice Kern Systems Inc. #CL-23 X 35 King St. N 268 Phillip St. X Waterloo, On Waterloo, On X Canada, N2J 2W9 Canada, N2L 6G9 X X XJudges' comments: X X Make and run with a filename (writable or to be created) as an argument. X For example, try: X X make ant X cp ant.hint hill X ant hill X X Note that some old BSD systems may have trouble compiling this entry. X They may complain about 'idlok' being undefined. You can fix this X by changing line 26 from: X X 2;initscr();d=LINES;raw();noecho();idlok(stdscr,1);if(0<(i= ... X to: X 2;initscr();d=LINES;raw();noecho();if(0<(i= ... X X ***or*** update to a modern version of Un*x. :-) If you have source, X you can use this entry to help in your upgrade. X X You may need to change the makefile depending on what type of system X you are running. See the notes in ansi.mk or common.mk. X X The author was kind enough to supply a list of references below, X in case you are still confused after read the source! :-) X X XSelected notes from the author: X X Ant's Editor vIOCCC91 X X Text files consists of lines of printable text or tab characters. X A line can be of arbitrary length and is delimited by either a X newline or the end of file. Carriage return is mapped to newline X on input and ignored on output. Tab stops are every eight columns. X Non-printable characters may have unpredictable results depending X on the implementation of CURSES. X X COMMANDS X h j k l left, down, up, right cursor movement X H J K L word left, page down, page up, word right X [ ] beginning and end of line X t b top and bottom of file X i enter insert mode, formfeed to quit X x delete character under the cursor X W write buffer to file X R refresh the screen X Q quit X X EXIT STATUS X 0 success X 2 missing edit filename X X The BUF size should be set at compile time to 32767. This value X was used because the Sozobon C compiler for the Atari ST has 16 X bit ints and a limit on the size of arrays & structures of 32k. X Also the WatCom C compiler for the PC also has 16 bits ints. On X machines that have 32 bit ints (most unix boxes), a larger value X for BUF could be used. X X It is recommend that compact memory model be used on PC class X machines. Small memory model may work too provided BUF is not X too large. X X The character constants '\b', '\f', '\n', '\r', '\t' are used X in order to provide more portable code, since the compiler should X handle the translation of them into the native character set. X Note that '\f' (formfeed) was used to exit insert mode because X K&R C had no escape constant for the escape-key. X X My goals for this project were to learn and experiment with the X Buffer Gap Scheme [Fin80][net90], write a useful and *portable* X programme, and meet the requirements of the IOCCC. I initially X planned to have a mini CURSES built-in like the IOCCC Tetris entry X from a previous year, however this was not as portable as using a X CURSES library with TERMINFO/TERMCAP support. X X I plan to post followups such as unobfuscated versions and bugs X fixes to comp.editors. Reposts of the editor.101, gap.doc, and X editor.102 can be found in the same group every so often. X X This entry will display a file with long lines, but has trouble X scrolling the screen with long lines. Paging up and down should X work correctly, however. X X REFERENCES X [Fin80] Craig A. Finseth, "Theory and Practice of Text Editors or X A Cookbook For An EMACS", TM-165, MIT Lab. for Computer X Science X X [KeP81] Kernighan & Plauger, "Software Tools in Pascal", X Addison-Wesley, 81, chapter 6 X X [Mil86] Eugene W. Myers & Webb Miller, "Row-replacement Algorithms X for Screen Editors", TR 86-19, Dept. of Computer Science, X U. of Arizona X X [MyM86] Eugene W. Myers & Webb Miller, "A simple row-replacement X method", TR 86-28, Dept. of Computer Science, U. of Arizona X X [Mil87] Webb Miller, "A Software Tools Sampler", Prentice Hall, 87 X ISBN 0-13-822305-X, chapter 5 X X [net90] "Editor 101/102" articles from comp.editors SHAR_EOF $TOUCH -am 0814003091 1991/ant.hint && chmod 0444 1991/ant.hint || echo "restore of 1991/ant.hint failed" set `wc -c 1991/ant.hint`;Wc_c=$1 if test "$Wc_c" != "4255"; then echo original size 4255, current size $Wc_c fi # ============= 1991/sorta.ifact2 ============== echo "x - extracting 1991/sorta.ifact2 (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.ifact2 && X[1+D2s*#`ld1s]:f X1 0 X1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f SHAR_EOF $TOUCH -am 0622130991 1991/sorta.ifact2 && chmod 0444 1991/sorta.ifact2 || echo "restore of 1991/sorta.ifact2 failed" set `wc -c 1991/sorta.ifact2`;Wc_c=$1 if test "$Wc_c" != "61"; then echo original size 61, current size $Wc_c fi # ============= 1991/buzzard.hint ============== echo "x - extracting 1991/buzzard.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/buzzard.hint && XBest Output: <buzzard@eng.umd.edu> Sean Barrett X X Sean Barrett X University of Maryland X 5407 20th Place X Hyattsville MD 20782 X USA X X XJudges' comments: X X Make and run as follows: X X make buzzard X buzzard X X You will be A-mazed. X X You are invited to try to cheat, ... if you can figure out how! :-) X X XSelected notes from the author: X X HOW TO PLAY: X X When the game starts, you are at the far end of the maze from the X exit, looking down a corridor. To move forward, type 'f' and press X return. To turn 90 degrees right, type 'r'; left, 'l'. You can X put multiple commands on one line, and the new view will be drawn X after all the moves. X X The game ends if you get out the exit (you'll know it when you see X it) or when you type ^D. X X HINTS ON HOW TO CHEAT: (rot13 to read) X X Lbh pna, bs pbhefr, purng ol ybbxvat ng gur znmr znc. Gur dhrfgvba X lbh arrq gb nfx lbhefrys, gubhtu, vf jung frdhrapr bs punenpgref X znexf gur cynpr jurer lbh pna rfpncr gur znmr? X X Gur nytbevguz vf dhvgr ovmneer--gur cevznel arfgrq ybbc gung X trarengrf vg tbrf gbc gb obggbz ba gur qvfcynl, ybbcvat sbejneq X gura onpxjneq sebz gur pheerag cbfvgvba gb qenj gur yrsg fvqr naq X gura gur evtug fvqr. X X ADVANCED USAGE NOTES: (rot13 to read) X X Gur cebtenz pna nyfb or eha sebz bgure svyrf pbagnvavat znmrf. Gur X znmr fubhyq or ynvq bhg tencuvpnyyl va gur boivbhf sbezng; arjyvarf X frcnengr culfvpny ebjf va gur znmr; n fcnpr vaqvpngrf n pbeevqbe, X naq nal bgure punenpgre vf n jnyy. Gnof ner nyfb pbafvqrerq jnyyf, X fb znxr fher gb pbaireg gnof gb fcnprf orsber hfvat vg. X X Hfntr: ohmmneq [svyranzr [rfpncr-pune [fgneg-k fgneg-l]]] X X Svyranzr vf gur anzr bs gur svyr pbagnvavat gur znmr. Guvf X qrsnhygf gb 'ohmmneq.p'. X X Rfpncr-pune vf gur punenpgre va gur znmr gung ercerfragf gur rkvg. X Lbh pna chg zber guna bar rkvg va gur znmr (sbe rknzcyr, lbh pbhyq X znxr nyy '!'f va gur znmr or rkvgf). X X Fgneg-k naq fgneg-l znex gur pbbeqvangrf jurer lbh ortva cynlvat. X L pbbeqvangr vf qbja gur ebjf va gur svyrf, K vf gb gur evtug X guebhtu gur punenpgref bs rnpu yvar. Obgu K naq L ortva pbhagvat X sebz 0. Gur qrsnhyg vf fgneg-k = 4, fgneg-l = 5, juvpu vf arrqrq X sbe gur ohmmneq.p, ohg jbhyq cebonoyl or vanccebcevngr sbe bgure X znmrf. X X OHTF: X X Lbh pna'g punatr gung ng fgneg lbh'er snpvat qbja ("fbhgu"). X X Gur qenjvat nytbevguz pnaabg unaqyr bcra fcnprf (gjb fhpprfvir X fvqr-pbeevqbef jvgu ab jnyy orgjrra gurz). Va snpg, vg pnaabg unaqyr X fznyy qbt-yrtf cebcreyl, nygubhtu gur reebe vf fhogyr. X X Gur rkvg vf qenja yvxr n abezny pbeevqbe sebz gur fvqr ivrj; X vg'f bayl qvfcynlrq nf gur rkvg jura lbh ner snpvat vg. X X Vzcebcre pbzznaqyvar nethzragf ner abg unaqyrq avpryl. X X Znmrf jvgu bcravatf ng gur rqtrf jvyy pnhfr gur qenjvat cebtenz X gb ernpu vagb neovgenel cnepryf bs zrzbel. X X Gur cebtenz nffhzrf gung gnof ner frg gb 8 punenpgref. SHAR_EOF $TOUCH -am 0814003191 1991/buzzard.hint && chmod 0444 1991/buzzard.hint || echo "restore of 1991/buzzard.hint failed" set `wc -c 1991/buzzard.hint`;Wc_c=$1 if test "$Wc_c" != "2968"; then echo original size 2968, current size $Wc_c fi # ============= 1991/cdupont.hint ============== echo "x - extracting 1991/cdupont.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/cdupont.hint && XMost Useful Label: <cdupont@ensl.ens-lyon.fr> Christian Dupont X X Christian Dupont X Ecole Normale Superieure de Lyon, X Laboratoire d'Informatique Parallele X 42, Rue H.Berlioz X 69009 Lyon X France X X XJudges' comments: X X Make and run as follows: X X make cdupont X cdupont X X Why is the following label necessary? X X sorryfor_this_unused_but_very_needed_label: X X Notice that if you C beautify (cb) or pre-process this program, it X will no longer work correctly, or at all. (go ahead, try it... :-)) X X NOTE: Due to minor problems with some ANSI C compilers, we have X supplied a more portable ANSI version. See the top level X README file for details. X X NOTE: One should remove the final trailing newline to obtain the X original source file. This step is not needed to compile X this entry. X X XSelected notes from the author: X X Spoiler, rot13 to read: X X Gur fbhepr pbqr ubyqf gur yrggref bs gur zrffntr. Rnpu yrggre, pbzovarq X jvgu nabgure xrl yrggre, vf hfrq gb pbzchgr gur pbbeqvangrf bs gur arkg X yrggre naq xrl. Guhf, gur zrffntr vf pbqr. Gung vf jul V hfr fvyyl X pbzzragf, zbfg bsgra onqyl fcnprq. X X Gur fcnpr punenpgre frdhrapr orgjrra gur jbeqf vf tvira ol n fvzcyr X pbzchgngvba ba na bpgny pbafgnag (tvira urer nf na urk inyhr, bs X pbhefr). X X Guvf jnl, nal zrffntr pna or zvkrq vagb n pbqr, fvapr gur xrlf nyybj X lbh gb cynpr gur zrnavatshy yrggref jurerire lbh jnag. SHAR_EOF $TOUCH -am 0814003191 1991/cdupont.hint && chmod 0444 1991/cdupont.hint || echo "restore of 1991/cdupont.hint failed" set `wc -c 1991/cdupont.hint`;Wc_c=$1 if test "$Wc_c" != "1428"; then echo original size 1428, current size $Wc_c fi # ============= 1991/fine.hint ============== echo "x - extracting 1991/fine.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/fine.hint && XBest One Liner: <fine@cis.ohio-state.edu> Thomas A. Fine X X Thomas A. Fine X Ohio State University X Department of Computer and Information Science X 2036 Neil Avenue Mall X Columbus, Ohio 43210 X USA X X XJudges' comments: X X Make and run as follows: X X make fine X echo "green terra X vex X tang X vend onyx X cheryl be flashy X rail X clerk" | fine X X This filter, 80 chars plus a newline, fits into a single line on most X terminals (unless your terminal has a line wrap mis-feature :-)). X X This entry is likely one of the smallest C implementations of this X filter, excluding programs that resort to command line or include X file tricks. X X How does this program work? Which 3 bytes of C code can be changed X into 2 bytes, allowing the program to still work, but also stripping X the high bit off of some input? X X XSelected notes from the author: X X The author wishes to thank J Greely for the last 6 bytes. X X Here's about how it does it: [rot13 to read] X X X ABGR: Ovgf ner ersreerq gb nf 76543210, uvtu gb ybj. X X 1. Trg gur punenpgre va inevnoyr n. Abgr gur sha jnl jr purpx sbe RBS. X (gunaxf W). X X 2. Erirefr ovg 6, naq fgevc ovg 5. Ovg 6 qrgrezvarf (zbfgyl) jurgure X be abg guvf punenpgre vf n yrggre. Ovg 5 jbhyq qrgrezvar pnfr vs X jr pnerq. Nffvta guvf inyhr gb inevnoyr o (Jr arrq gb fnir vg, X fvapr jr arrq gb znxr 2 pbzcnevfbaf naq znlor bar bcrengvba jvgu X guvf inyhr). Jr pna'g nohfr bhe svefg inevnoyr, fvapr vg fnirf gur X ovgf jr'er punatvat. X X 3. Purpx guvf inyhr gb frr vs vg vf n yrggre. Vg zhfg or aba-mreb - X vs vg vf mreb, gura jr unir rvgure gur ng-fvta (64) be gur X onpxdhbgr (96). Vg nyfb zhfg or yrff guna 27 - guvf purpxf gur X enatr sbe yrggref nf jryy nf vzcyvpvgyl purpxvat gur inyhr bs ovg 6 X (vs vg jnf bevtvanyyl pyrne, vg vf frg abj, fb o jbhyq or gb ovt). X X 4. Vs vg vf abg n yrggre, gur pbaqvgvbany rkcerffvba vafvqr bs gur X chgpune() ergheaf gur bevtvany punenpgre (n). Bgurejvfr, vg X ergheaf n ernyyl zrffl rkcerffvba gung cresbezf gur npghny ebgngvba X naq svkrf gur svsgu naq fvkgu ovgf: X X N. Fhogenpg 1, gb trg vagb gur enatr 0-25 (sbe gur zbqhyb bcrengvba). X O. Nqq 13 gb gur punenpgre. Fgrcf N naq O ner pbzovarq. X P. Gnxr guvf zbqhyb 26 gb znxr gur nqqvgvba jenc nebhaq. X Q. Svk ovgf 5 naq 6, onfrq ba inevnoyr n. X R. Nqq 1 onpx va (jr gbbx vg bhg va fgrc N.) Guvf vf bxnl gb qb X *nsgre* fgrc Q, orpnhfr jr xabj gur nqqvgvba jba'g gevpxyr hc X cnfg gur sbhegu ovg (o jbhyq unir gb or 31 sbe guvf gb unccra). X X Abgvpr gung guvf vzcyrzragngvba bcrengrf bayl ba punenpgref jvgu gur X uvtu ovg pyrne. Gur uvtu ovg pna or vtaberq jvgubhg punatvat gur fvmr X bs gur cebtenz. Nyfb, vs lbh xabj lbh ner bayl qrnyvat jvgu frira ovg X qngn, gur fvmr pna or erqhprq ol bar olgr. Gurfr ner yrsg nf rkrepvfrf X sbe gur fghqrag. X SHAR_EOF $TOUCH -am 0814003291 1991/fine.hint && chmod 0444 1991/fine.hint || echo "restore of 1991/fine.hint failed" set `wc -c 1991/fine.hint`;Wc_c=$1 if test "$Wc_c" != "2987"; then echo original size 2987, current size $Wc_c fi # ============= 1991/rince.hint ============== echo "x - extracting 1991/rince.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/rince.hint && XBest Game: <rince@cs.warwick.ac.uk> James Bonfield X X James Bonfield X University of Warwick X 7 Water End, X Wrestlingworth, X Sandy Beds, X SG19 2HA X England X X XJudges' comments: X X Make and run as follows: X X make rince X rince X X This entry exposed a number of bugs in a number of ANSI C compilers! X Because of this, we have provided a number of different versions: X X rince.orig.c - James Bonfield entry X (many non-GNU ANSI compilers can't grok this code) X rince.c - our non-ANSI version of rince.orig.c X rince_ansi.c - same as rince.c X (most ANSI C compilers can deal with this) X X You may need to change the makefile depending on what type of system X you are running. See the notes in ansi.mk or common.mk. X X XSelected notes from the author: X X This program is a simple puzzle type game. (I'll leave you to play X it to see the rest of it .. :-) .) The general idea was to try and X write the smallest playable game, but keep the playability and X enjoyment high. X X Instructions (rot 13 to read). X ============================== X X Xrl gb znc:- X X | X ###### | | | /\ /--\ ==| /\ | | Qverpgbany xrlf X ###### Fbyvq Jnyy | ----|| \/ /\ ||---- (haybpx qbbef bs X ###### | \/ ==| \--/ \/ gur fnzr qverpgvba) X | X | << >> Qbbef. Haybpxrq ol X Oynax fcnpr | << iiiiii ^^^^^^ >> gur nobir xrlf. X | << >> X | X ___ | b__B\ B__B ^__^ /B__b X / \ 'Pehfunoyr' | \___/ /----\ /----\ \___/ Gur sbhe fcevgrf sbe X \___/ obhyqre | _/_\ _/ \_ _/ \_ /_\_ lbhe punenpgre :-) X | X ___ hapehfunoyr | /\ Qvnzbaqf. Gurl pna rvgure or sbhaq ylvat X /@@@\ obhyqre | < > nebhaq (vs bayl!) be znahsnpgher ol chfuvat X \@@@/ | \/ gjb 'pehfunoyr' ebpxf gbtrgure. X | X X Gur trareny vqrn bs gur tnzr vf gb pbyyrpg nyy gur qvnzbaqf. Guvf zhfg X or qbar va gur zvavzhz nzbhag bs zbirf. V'ir nyybjrq n znetva bs 5 X zbirf juvpu oevatf gur zbirf nyybjrq gb 484. (nygre gur inyhr bs 'h' va X gur cebtenz gb frg gur znk zbirf nyybjrq) X X Gurer ner gjb glcrf bs obhyqref. Obgu pna or chfurq nebhaq, ohg bayl X gur ubyybj (pehfunoyr) barf pna or ghearq vagb qvnzbaqf (ol chfuvat vg X bagb nabgure ubyybj bar). X X Bs gur sbhe glcrf bs qbbef (naq xrlf) bayl 3 unir orra qrsvarq. Guvf X jnf qbar gb xrrc gur fbhepr nf ybj nf cbffvoyr (nf V bayl hfrq 3 va gur X znc). Gb haybpx n qbbe fvzcyl chfu n xrl vagb gur pbeerfcbaqvat qbbe. X Gnxr pner gung vg'f snpvat va gur pbeerpg qverpgvba. SHAR_EOF $TOUCH -am 0814004091 1991/rince.hint && chmod 0444 1991/rince.hint || echo "restore of 1991/rince.hint failed" set `wc -c 1991/rince.hint`;Wc_c=$1 if test "$Wc_c" != "2798"; then echo original size 2798, current size $Wc_c fi # ============= 1991/sorta.ifact3 ============== echo "x - extracting 1991/sorta.ifact3 (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.ifact3 && X[1+D2s*#`ld1s]:f [ given (n-1)! (n-1), print n!, put n! n ] X[2s1=f2s1_+D0>=x]:x [ given n n! x, print (n+1)! through (n+x)! ] X0 1 10 1=x SHAR_EOF $TOUCH -am 0622130991 1991/sorta.ifact3 && chmod 0444 1991/sorta.ifact3 || echo "restore of 1991/sorta.ifact3 failed" set `wc -c 1991/sorta.ifact3`;Wc_c=$1 if test "$Wc_c" != "146"; then echo original size 146, current size $Wc_c fi # ============= 1991/sorta.irot13 ============== echo "x - extracting 1991/sorta.irot13 (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.irot13 && X"[] [.tr] " X["]".[a-m][n-z][A-M][N-Z]"[" ]TTT ["]".[n-z][a-m][N-Z][A-M]"[" ]TTT X"[tr] !q"T:xld X["rot13: fatal: need exactly one argument"`q]:gld X["rot13: fatal: cannot open "1ST`q]:hld Xa2_+=g X1A 0 [ that 0 is for RDONLY ]ld X 0 'o D0 1s>=hld X0Ou1=x [ in a more complex spawner, this would be done under a fork ]ld SHAR_EOF $TOUCH -am 0622131091 1991/sorta.irot13 && chmod 0444 1991/sorta.irot13 || echo "restore of 1991/sorta.irot13 failed" set `wc -c 1991/sorta.irot13`;Wc_c=$1 if test "$Wc_c" != "318"; then echo original size 318, current size $Wc_c fi # ============= 1991/sorta.isleep ============== echo "x - extracting 1991/sorta.isleep (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.isleep && X["" "+sleep" "+5" "sleep" !q]:S [F0>1_+=S]:s X"forking sleep 5..."`ld X1=s X"waiting for sleep to finish..."`ld Xw X"done, sleep exit code " #T` SHAR_EOF $TOUCH -am 0622131091 1991/sorta.isleep && chmod 0444 1991/sorta.isleep || echo "restore of 1991/sorta.isleep failed" set `wc -c 1991/sorta.isleep`;Wc_c=$1 if test "$Wc_c" != "140"; then echo original size 140, current size $Wc_c fi # ============= 1991/sorta.itailrec ============== echo "x - extracting 1991/sorta.itailrec (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.itailrec && X[3*#" "T$ldD=f]:f X1=f SHAR_EOF $TOUCH -am 0622131091 1991/sorta.itailrec && chmod 0444 1991/sorta.itailrec || echo "restore of 1991/sorta.itailrec failed" set `wc -c 1991/sorta.itailrec`;Wc_c=$1 if test "$Wc_c" != "22"; then echo original size 22, current size $Wc_c fi # ============= 1991/sorta.iwhosort ============== echo "x - extracting 1991/sorta.iwhosort (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/sorta.iwhosort && X[0Ou "" "+-u" "sort" !q]:S [F0>1_+=S]:s X[1Ou "" "+-u" "who" !q]:W [F0>1_+=W]:w XP1=wO1=sOww SHAR_EOF $TOUCH -am 0622131091 1991/sorta.iwhosort && chmod 0444 1991/sorta.iwhosort || echo "restore of 1991/sorta.iwhosort failed" set `wc -c 1991/sorta.iwhosort`;Wc_c=$1 if test "$Wc_c" != "92"; then echo original size 92, current size $Wc_c fi # ============= 1991/brnstnd.c ============== echo "x - extracting 1991/brnstnd.c (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/brnstnd.c && X#include <stdio.h> X#define D define X#D H(x,y,z) f(p){--p;c=x-_+1];f(c>0){y+1]=z[c];z[c]=y];y]=y+1];}} X#D O(x,y) F(x,int U;int T=0;d=M(U=1);W{f(c==y)b g[T++]=c;f(T==U)g=realloc(g,U<<=1);}g[T]=0;) X#D W Y((c=k?K[--k]:getchar())-EOF) X#D S i[q X#D F(w,z) f(c==w){z h} X#D f if X#D P p>1&&(c=u, X#D _ s[p X#D C =G X#D g S] X#D J(x,y) F(I[x],y) X#D Q P e X#D Y while X#D b break; X#D u _--] X#D m p&& X#D R char* X#D l Z[c] X#D L strlen X#D d i[++q] X#D G c) X#D h ;continue; X#D N s[++p] X#D e _] X#D j x;{R r=M(L( X#D v return X#D w [256] X#D V f(k>o||p>o||q>o)v 2; XR I="I'd love ta win: the most useful !$>%`/#<&*|^ _OBFUSCATED_ utility. Pleez?";U(y,x)R y;R*j*x)+L(y)+1);sprintf(r,"%s%s",*x,y);*x=r;}R T(x)R j x)+1);strcpy(r,x);v Xr;}R(i w);static R(Z w);K w;main(a,A)int a;R*A;{int s w,p=0,q=0,n=0,c,k=0;W{V Xf(c>='0'&&c<='9'){f(!n)N=0;n=1;e=10*e+(c-'0')h}n=0;J(39,m Xsprintf(d=M(13),"%d",e)) XJ(37,q&&puts(g))J(34,q&&printf("%s",g))J(27,H(p,_,s))O('[',']')J(56,f(p){c=e;N=c;})J(2,m--p)J(10,N=a)J(4,f(q){N=L(g);X(S--]);})J(1,f(q){S+1]=T(g);++q;})J(53,m Xe>=0&&e<a&&(d=T(A[u]))) XJ(54,q>1&&(--q,U(S+1],i+q)))J(5,q&&p>1&&(_-1]=open(g,_-1],e),--p,X(S--])))J(47,m Xclose(u)) XJ(26,m(e=dup(e)))O('"','"')J(51,H(q,S,i))J(49,N=fork())J(12,wait(&N)+1||(e=-1))J(68,{++p;pipe(s+p++)==-1&&(e=-1);})F('q',v X0) XF('=',W{R x;f(m u)f(x=l){k+=n=L(x);V;Y(*x)K[--k]=*x++;k+=n;n=0;}b})J(15,f(q)W{l&&X(l);l=T(g);b})J(33,f(c=q){*i=g;g=0;Y(--q&&**(i+q))g++;f(q){N=execvp(*i,i+q+1);q=c;}})J(38,P Xc&&(e/C)) XJ(35,Q=e>G)F('+',Q+C)J(42,Q*C)J(41,Q=~(e&G))J(57,m(e=-e))J(3,)F('\n',)putchar(c);puts(73+I);}} SHAR_EOF $TOUCH -am 0807142891 1991/brnstnd.c && chmod 0444 1991/brnstnd.c || echo "restore of 1991/brnstnd.c failed" set `wc -c 1991/brnstnd.c`;Wc_c=$1 if test "$Wc_c" != "1542"; then echo original size 1542, current size $Wc_c fi # ============= 1991/davidguy.hint ============== echo "x - extracting 1991/davidguy.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/davidguy.hint && XBest X11 Graphics: <david+@cs.cmu.edu> David Applegate X <guy@ulysses.att.com> Guy Jacobson X X David Applegate Guy Jacobson X School of Computer Science AT&T Bell Laboratories X Carnegie Mellon University 600 Mountain Avenue X Pittsburgh PA 15213 Murray Hill NJ 07974 X USA USA X X XJudges' comments: X X Make and run as follows: X X make davidguy X davidguy ip_address:server.screen X X where 'ip_address' in an IP address of an X server. For example, try: X X davidguy 127.0.0.1:0.0 X X Of course, may need to supply a more reasonable address. :-) X X Also try: X X cp davidguy guydavid X guydavid 127.0.0.1:0.0 X X Can you determine why this makes a difference. X X We permitted this type of entry to win because: X X - it did not require X to be on the host system X - both BSD and SVR4 have sockets X X Now that X11 and sockets have become 'standard', we plan to open X up the contest to programs that use them. Future rules will X explain this further. X X We are pleased that this entry has helped bring new 'life' into X the contest. X X NOTE: The orignal program that won may be found in davidguy.orig.c. X The author supplied a second version of the program, which X we have placed in the default location davidguy.c. X X XSelected notes from the authors: X X The program is a fully-functional X client. It talks directly to X the X server through a socket without using Xlib, Xt or any other X wussie toolkit junk. With no arguments, it will try to run X locally using the unix-domain socket (only on BSD :-( ) or you can X give it a command line argument identifying a display host address X (in dotted octet notation, like 127.0.0.1:0.0) where the X server X is running. It handles color and monochrome displays, and X performs whatever byte-swapping and bit-reversal is needed (so X that the program works even when the server and the client have X different architectures). It buffers communication to the X X server for efficiency. X X [[ NOTE: The original source in davidguy.c used only an IP address X argument (assumed :0.0) and assumed the color of black X and white. ]] X X The program doesn't require any user interaction; you can just sit X back and watch it run. All the action takes place in the root X window of the display. X X We think the program is interesting for these reasons: X X 1) It belongs to a class of programs that programmers make X the following complaints about: they require a mountain X of code to implement even the simplest program; and they X must be linked with giant libraries of hard-to-understand X functions. In contrast to these complaints (made by wimps, X in our humble opinion), our program fits in under 1536 X bytes, doesn't need any external functions except for a few X system calls, and doesn't need to include any header files. X X 2) It implements an extremely efficient algorithm for the X computation it performs. One cool feature of the algorithm X (at least as far as this contest is concerned) is that its X obscurity is fundamentally necessary for its efficiency. X In other words, even if we took steps to present the algorithm X clearly, (we haven't) the relation of the computation performed X to the specification of what the program was supposed to do X would still be hard to understand. X X Quasi-spoiler on internals: X X The program plays Conway's game of Life in the root window's X background pixmap. It starts by setting the background to random X bits, and then plays Life, with one Life cell for each pixel of the X screen. In the game of Life, a cell survives to the next round if X 2 or 3 of its 8 neighbors are also alive, and a cell is born if X exactly 3 of its neighbors are alive. Otherwise, a cell dies of X exposure if it has only 0 or 1 neighbors, and dies of overcrowding X if it has 4 or more neighbors. X X The algorithm used to compute the next generation is based on the X observation that a cell's state in the next generation is a boolean X function of its current state, and the states of its 8 neighbors X (ie, a boolean function from 9 bits to 1 bit). This function can X be computed by a boolean circuit. In addition, intermediate values X computed by the circuit can be shared between neighboring cells, X reducing the number of gates per cell required. These ideas X have been used before, to compute the next generation through a X series of bit blits. Instead of doing this, we map values in the X circuit to bits in registers, so that the next generation can be X computed efficiently within registers, minimizing memory accesses. X As a result, the computation of the next generation is performed X with about 1.6 instructions per life cell, consisting of .125 X memory accesses, .17 shifts, and 1.3 logic operations. The net X result is that the time to transfer the bits to the X server, and X for the X server to draw them on the screen, dominates the time to X compute the next generation. SHAR_EOF $TOUCH -am 0814003291 1991/davidguy.hint && chmod 0444 1991/davidguy.hint || echo "restore of 1991/davidguy.hint failed" set `wc -c 1991/davidguy.hint`;Wc_c=$1 if test "$Wc_c" != "5061"; then echo original size 5061, current size $Wc_c fi # ============= 1991/brnstnd.hint ============== echo "x - extracting 1991/brnstnd.hint (Text)" sed 's/^X//' << 'SHAR_EOF' > 1991/brnstnd.hint && XBest Of Show: <brnstnd@nyu.edu> Daniel J. Bernstein X X Daniel J. Bernstein X New York University X X XJudges' comments: X X Make and run. Try: X X make brnstnd X brnstnd < sorta.i2+2 X X For info on more examples, read the sorta.README file. X X The author wished to win the "most useful program" award and X documented this in the source code. The judges were unmoved X by this blatant attempt to influence the contest and rejected X this idea... so we gave it the Best of Show award instead!! X X NOTE: Due to minor problems with some ANSI C compilers, we have X supplied a more portable ANSI version. See the top level X README file for details. X X NOTE: One should remove the final trailing newline to obtain the X original source file. This step is not needed to compile X this entry. X X XSelected notes from the author: X X This is an interpreter for the programming language SORTA, a systems X and numerical programming language with features sorta from C, sorta X from FORTH, and sorta from Ada. X X SORTA lets you manipulate files and spawn programs easily, has bitwise X operators, and gives you absolutely brilliant error messages like '?' X (that's the C bit). SORTA programs work with a stack (that's the FORTH X bit)---actually two stacks, one for integers and one for strings. And X all SORTA operations are strongly typed, detect practically any failure, X and garbage-collect (that's the Ada bit). X X SORTA also contains features you might not expect from such a small X interpreter: arbitrary-length string input and concatenation, for X instance, not to mention infinite-depth tail recursion. X X SORTA ignores its arguments (though it makes them available to the X script); it takes all commands, character by character, from its X standard input. Unrecognized commands are repeated with a ?. X X SORTA maintains an ``i stack'' for integers and an ``s stack'' for X strings. It also keeps track of ``programs,'' one for each character. X Operations are silently ignored if the relevant stacks are too low, X except as noted for s, S, and !. If the i stack or s stack (or the stack X of buffered macro commands) grows too high, SORTA will exit silently X with exit code 2. (Compile parameter -Do=250 controls what ``too high'' X means; you should not make o larger than 250.) I don't think it's X possible to crash the interpreter. X X Here, then, is the SORTA programming language. All non-digits delimit X numeric constants. Spaces and newlines are ignored except as numeric X delimiters. X X Basic operations: X X q: quit X number: push that number on top of the i stack X "string": push that string on top of the s stack, no length limit X [string]: push that string on top of the s stack, no length limit X #: make top of i stack non-destructively in ASCII, push result onto s stack X `: print top of s stack non-destructively X $: print top of s stack non-destructively without newline X d: drop (pop) top of i stack X D: dup (duplicate) top of i stack X ': dup top of s stack X s: pop top of i stack. If it is n, swap (n+1)th-top of i stack with top. X 1s, for example, swaps the top two elements; 2s swaps the top with X the third down; etc. This always pops the top of the i stack, even X upon failure. X S: pop top of i stack, then act just like s but upon s stack X l: pop top of s stack, push its length onto i stack X a: push argc onto i stack X A: pop top of i stack, push argv[i] on top of s stack X T: concatenate top two elements of s stack X _: negate top of i stack X +: pop top two elements of i stack, add, push back sum X *: pop top two elements of i stack, multiply, push back product X /: pop top two elements of i stack, divide, push back quotient X >: pop top two elements of i stack, compare, push back 1 or 0 as in C X &: pop top two elements of i stack, nand, push back bitwise result X Note that nand is sufficient to construct all bitwise operations, X as demonstrated by icalc below. X X System operations: X X o: pop top of s stack and top two of i stack; open(s1,i2,i1); leave X result on i stack X O: pop top of i stack, close() it X u: pop top of i stack, dup() it, push result back on X F: fork(), push result on i stack. This is not always safe while SORTA X is reading keyboard input or a script, as the forked programs share X file descriptors. It is always safe inside a program (see below). X P: pipe(), push two ends <p0> <p1> onto i stack. In case of trouble, X push <?> <-1> onto i stack. X w: wait(), push successful result (or -1 if no children) on i stack X !: execvp() top of the s stack. Arguments are the next things down on X the s stack, in reverse order from popping; the first character of X each string is lopped off. There must be an empty string somewhere X in the s stack to terminate the argument list. If the execve() X fails, any operation involving current members of the s stack has X undefined effects, and -1 is pushed onto the i stack. X X High-level language operations: X X :x: copy the top of the s stack into a program labeled by character x X =x: pop the top of the i stack. If it was nonzero, execute the program X labeled by character x. Note that a digit at the end of a program X will merge with any digits after =x; in that case you usually want X to add a space at the end of the program. X X Common idioms: To drop the top of the s stack, ld. To do a <, 1s>. To X unconditionally execute the program labeled by character x, 1=x (or any X nonzero number followed by =x). To print the top of the i stack X non-destructively, #` (or #$ if you don't want the newline). To X subtract, _+. To do mod or and or any of the other missing operations, X combine the available operations as illustrated below. To introduce a X comment, [ this is a comment string which is promptly eliminated ]ld. X X SORTA's requirements: it wants fork(), execvp(), open(), X close(), dup(), pipe(), and wait(), so it obviously won't even compile X on a non-UNIX machine. It also assumes that you have a size-256 X character set and that the characters between '0' and '9' are exactly X the digits in order. It does *not* depend on ASCII, despite the code X appearance. Also note that SORTA does not attempt to declare malloc(), X so you will get some warnings about illegal pointer combinations. Also X note that there are unreached statements in SORTA. X X While the program source of course depends highly on #defines for X obfuscation, I like to think that this code has those little touches, X those professionally sharpened edges that mark true software X engineering. Observe, for instance, how i and s are the string and X integer stacks respectively. It's these little things that make you X feel at home in an otherwise utterly useless piece of code. They're X what make an obfuscation work. X X The character pool (``I'' after cpp) makes it rather painful to X see the effect of commands at a glance. I can just imagine people X spending hours bouncing between the pool and the rest of the code, X or accidentally changing the pool without realizing its importance. X Without documentation and example scripts, someone would find it X a challenge to figure out what the arrays are used for, let alone X that SORTA is a scripting language. X X Another nice feature is that the SORTA language itself encourages X you to write not merely obfuscated but plain incomprehensible X scripts (like the examples below---after working with the language X for a while, I guess I can read it pretty easily, but I also think X FORTH is a beautiful language). The numbers running around X everywhere will make people think of ASCII, even though the code is X not ASCII-dependent. What's your first thought when you see X several arrays[256]? This is pretty standard obfuscation otherwise. X I like the way that unbalanced macro braces can throw off the X reader in ``if(c>0){y+1]=z[c];'', and I had fun covering the X alphabet with #defines, but that's nothing special. X X Possible future extensions to SORTA include string extraction and X matching, reading from files into strings, and encrypting the string X pool to further confuse the judges. I don't think I can fit this into X the size limit, unfortunately. SHAR_EOF $TOUCH -am 0814003191 1991/brnstnd.hint && chmod 0444 1991/brnstnd.hint || echo "restore of 1991/brnstnd.hint failed" set `wc -c 1991/brnstnd.hint`;Wc_c=$1 if test "$Wc_c" != "8418"; then echo original size 8418, current size $Wc_c fi exit 0 -- For a good prime, call: 391581 * 2^216193 - 1