1990 International Obfuscated C Code Contest Winners
Landon C. Noll
chongo at hoptoad.uucp
Thu Jul 12 21:01:45 AEST 1990
The shar file below contains the 1st public release of the winners of the
1990 International Obfuscated C Code Contest.
Prior to submitting these winners to UUNET source archives, we would
like to collect porting comments, If you run encounter problems
compiling/running these programs and YOU HAVE A FIX, please send
a PATCH FILE (diff -c) via Email to:
...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!judges
judges at toad.com
We expect that a number of problems will be encountered on some systems,
so we would like to include a number of PATCH fixes along with the
2nd public release.
Comments on the included text (in the form of a PATCH) are welcome too.
The 1991 international Obfuscated C Code Contest will start when the
1991 rules are posted to this newsgroup. This will happen around
the beginning of March 1991. Please wait until the new 1991 rules
are posted before sending in new contest entries. If you think you
have missed the 1991 rules posting and it is after March 15, 1991,
send us a note (to the address above) requesting a copy and we will
attempt to Email them to you.
chongo <Happy Hacking, Share & Enjoy> /\cc/\
# This is a shell archive. Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file". (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# README Makefile ansi.mk common.mk baruch.c cmills.c dds.c dg.c jaw.c pjr.c
# scjones.c stig.c tbr.c theorem.c westley.c baruch.hint cmills.hint dds.hint
# dg.hint jaw.hint pjr.hint scjones.hint stig.hint tbr.hint theorem.hint
# westley.hint LANDER.BAS stig.ksh shark.sh rules
: =-=-=-=-=-=-= first line of shar 1 of 1 =-=-=-=-=-=-=-=-=-
echo mkdir ./1990
mkdir ./1990
echo cd ./1990
cd ./1990
echo x - README
sed -e 's/^X//' > "README" << '//E*O*F README//'
X1990 marked the "The Seventh International Obfuscated C Code Contest"
X
XInstructions for use: Run make to compile entries (it is possible that
Xon System V or non-unix systems the makefile needs to be changed). The
Xansi.mk may need to be changed if your ANSI C compiler is not gcc.
X
XLook at the source and try to figure out what the programs do, and run
Xthem with various inputs. If you want to, look at the hints files for
X(minor) spoilers.
X
XThis year, the Grand Prize won a standing ovation at USENIX.
X
XThe "Strangest abuse of the rules" award was given this year to stress
Xthe fact that starting in 1991, entries should be shell-specific.
X
XThis year was the first year that we accepted ANSI C entries. It was
Xinteresting to note that the ANSI C entries were as a whole less
Xportable than the K&R C entries. We hope that in future contests
Xpeople will enter more obfuscated and challenging ANSI C programs.
X
XWe would like to thank Barbara Frezza (loving wife of Larry Bassel) for
Xher role as official chef of the contest. Her opinions regarding
Xsome of the contest entries were appreciated.
X
XRules and results were posted to comp.lang.c, comp.sources.unix, and
Xalt.sources. They have been made available on a wide number of Usenet
Xarchive sites such as uunet.
//E*O*F README//
echo x - rules
sed -e 's/^X//' > "rules" << '//E*O*F rules//'
X7th International Obfuscated C Code Contest Rules
X
X Obfuscate: tr.v. -cated, -cating, -cates. 1. a. To render obscure.
X b. To darken. 2. To confuse: his emotions obfuscated his
X judgment. [LLat. obfuscare, to darken : ob(intensive) +
X Lat. fuscare, to darken < fuscus, dark.] -obfuscation n.
X obfuscatory adj.
X
XGOALS OF THE CONTEST:
X
X * To write the most Obscure/Obfuscated C program under the rules below.
X * To show what should NOT be done in C programs.
X * To provide a safe forum for poor C code. :-)
X
XDEDICATION:
X
X The 1990 International Obfuscated C Code Contest is dedicated to ANSI C.
X
XRULES:
X
X To help us handle the vast volume of entries, we ask that you
X follow the rules below. Sorry for the length, but we need all
X the help we can get!
X
X 1) Your source MUST be 1536 bytes or less, and it must be a complete
X program, not just a subroutine.
X
X 2) To help us process your entries, we ask that you submit entries
X in the following format. Please be sure to include ALL --- lines,
X otherwise our extraction program may skip your entry!
X
X---header items---
Xname: Your name, of course!
Xorg: School/Company/Organization
Xemail address: Email address from a well known site, or in a registered domain
Xpostal address: Postal address
X include your country as well
Xenvironment: Indicate the Hardware
X and OS under which your program was tested
Xentry: 5 <number of entries sent so far including this one>
Xremarks: Remarks may be continued with leading whitespace until the
X line ---how to compile-- is encountered. (see #3 below)
X---how to ANSI compile---
XX Give the command(s) needed to compile your program using an ANSI C
XX compiler. If you program should not be compiled under an ANSI C compiler,
XX leave this section blank. Follow the format rules for the program
XX section below, except that command size must be 160 characters or less.
X---how to common compile---
XX Give the command(s) needed to compile your program using an K&R/traditional
XX C compiler. If you program should not be compiled under a K&R style C,
XX leave this section blank. Follow the format rules for the program section
XX below, except that command size must be 160 characters or less.
X---program---
XX Place obfuscated source of 1536 characters or less in this section.
XX Add a leading X to each line to avoid problems with mailers.
XX Some mailers don't like files with very long lines. If your entry contains E
XC lines longer 80 chars we ask you to form continuation line sets. To form E
XC a continuation line set, place an 'E' character at the point of a split E
XC and place a C (instead of an X) at the beginning of the next line. E
XC Finally, end the continuation line set as normal.
XX The E\nC's and leading X's will be removed prior to extraction and thus E
XC they don't contribute toward the source character count. All other E
XC characters are considered to be source. Whitespace after 'X' or 'C' E
XC and before the 'E' is significant, we added it here for readability.
XX Newlines and tabs each count as 1 character. Assume 8 character tab stops.
XX If your entry does not end in a newline, leave a final 'E' on the end. E
X---end---
X
X 3) Regarding the header items:
X
X * Any text outside of the above format will be kept confidential.
X
X * All header lines are required, but you may use 'anonymous'
X for any header line other than 'remarks' or 'entry'.
X
X * In the 'remarks' please include:
X - what this program does
X - why you think the program is obfuscated
X - any other remarks (humorous or otherwise)
X
X 4) Your entry should be written in common C (K&R + common extensions)
X or ANSI C. If your program will NOT compile under an ANSI C or
X K&R C compiler, leave the particular 'how to' section blank.
X
X You do not have to fill in both 'how to' sections, though you must
X fill in at least one 'how to' section.
X
X If you leave a 'how to' section blank, include the '---' line, but
X but having no command lines after it.
X
X 5) The program must be of original work. All programs must be
X in the public domain. All copyrighted programs will be rejected.
X
X 6) Entries must be received between 16-Mar-90 0:00 GMT and
X 26-May-90 0:00 GMT. Email your entries to:
X
X ...!{sun,pacbell,uunet,utzoo,pyramid,amdahl}!hoptoad!obfuscate
X
X We will attempt to Email a confirmation of receipt of contest
X entries, however since Email is not reliable you may not receive it.
X We regret that we can no longer accept entries via postal mail.
X
X 7) Each person may submit up to 8 entries. Multiple entries must
X be sent in separate Email letters.
X
X 8) Entries that can not be built automatically in a portable makefile
X are not allowed. (e.g., don't use #include "/dev/tty")
X
X 9) Starting this year, compiling entries must result an regular file
X which can be executed. (No -o /dev/tty or similar compile lines)
X
X
XANNOUNCEMENT OF WINNERS:
X
X * First announcement will likely be at the Summer 90 Usenix BOF.
X
X * Winning entries will be posted in mid June 1990 to
X comp.sources.unix as well as news groups where these rules
X were posted. (depending on the judges work load)
X
X * Winning entries will be deposited into the uunet archives.
X
X * An article containing the winning entries will be published
X in a future issue of the "Micro/Systems Journal".
X
X * Winners receive international fame and flames! :-)
X
X
XJUDGING:
X
X Awards will be given to the best entry in a number of categories.
X The actual category list will vary depending on the types of entries
X we receive. As a guide, consider using the following:
X
X * The best small one line program
X * The strangest source layout
X * The most useful obfuscated program
X * The most creatively obfuscated program
X * Best obfuscated entry smaller than 256 bytes
X * Best obfuscated entry smaller than 1024 bytes
X * Best abuse of ANSI
X * Worse abuse of the rules (no abuse of entry format please!)
X * <anything else so strange that it deserves an award>
X
XPOINTS TO PONDER:
X
X People are encouraged to examine winners of the previous
X contests. A copy of these entries was posted to
X comp.sources.unix. Contact the comp.sources.unix moderator, or
X some archive site (such as uunet). Keep in mind that rules
X change from year to year, so some winning entries may not be
X valid entries this year. What was unique and novel one year
X might be 'old' the next year. In short, use your best judgment.
X
X We examine each entry on several levels of confusion. For example
X each entry is judged when we:
X
X * look at the original source
X * run it through: sed -e ',^#[ ]*define,d' | /lib/cpp
X * run it through: sed -e ',^#[ ]*include,d' | /lib/cpp
X * run it through a C beautifier
X * examine the algorithm
X * compile and lint it
X * execute it
X
X One line programs are best when they are short, obscure and concise.
X
X We tend to dislike programs that:
X
X * are very hardware specific
X * are very OS or Un*x version specific
X (index/strchr differences are ok, but socket/streams specific
X code is likely not to be)
X * dump core or have compiler warnings
X (it is ok only if you warn us in the 'remark' header item)
X * won't compile under both BSD or SYS V Un*x
X * use an excessively long compile line to get around the size limit
X * are longer than they need to be
X * are similar to previous winners
X * are similar to previous losers :-)
X
X Simply abusing #defines or -Dfoo=bar won't go as far as a program
X that is more well rounded in confusion.
X
X Unless you are cramped for space, or unless you are entering the
X 'best one liner' category, we suggest that you format your program
X in a more creative way than simply forming excessively long lines.
X
X We like programs that:
X
X * are as concise and small as they need to be
X * do something quasi-interesting
X * pass lint without complaint (particularly strict ANSI ones)
X * are portable
X * are unique or novel in their obfuscation style
X * MAKE USE OF A NUMBER OF DIFFERENT TYPES OF OBFUSCATION
X * make us laugh and/or throw up :-)
X
X Some types of programs can't excel in some areas. Of course, your
X program doesn't have to excel in all areas, but doing well in several
X areas really does help.
X
X Be creative!
X
X The Judging will be done by Landon Noll and Larry Bassel. If you have
X any QUESTIONS or COMMENTS, please feel free to send them to:
X
X ...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!judges
X judges at toad.com
X
X however contest entries should be sent to:
X
X ...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!obfuscate
X obfuscate at toad.com
X
X
Xchongo <Landon Curt Noll> /\cc/\ hoptoad!chongo
XLarry Bassel {amdahl,ucbvax,cbosgd}|sun!lab
//E*O*F rules//
echo x - Makefile
sed -e 's/^X//' > "Makefile" << '//E*O*F Makefile//'
X# %W% %G% %U%
X#
X# 1990 makefile
X
XSHELL=/bin/sh
XMAKE=make
XMAKEFLAGS=e
X
X# uncomment the line to select the preferred type of compile
X#
X# You should also check the ansi.mk or common.mk for the
X# proper compiler name and flags.
X#
X# NOTE ==> USE=ansi compile with an ANSI compiler by default
X#USE=ansi
X# NOTE ==> USE=common compile with a common K&R compiler by default
XUSE=common
X
XWINNERS=cmills pjr westley stig tbr db dds theorem baruch jaw scjones
X
Xall:
X - at if [ ${USE} = common ]; then \
X ${MAKE} -f common.mk all; \
X elif [ ${USE} = ansi ]; then \
X ${MAKE} -f ansi.mk all; \
X else \
X echo "set USE= in Makefile to be ansi or common as desired"; \
X echo "or type: make -f ansi.mk for ansi makes"; \
X echo "or type: make -f common.mk for common K&R makes"; \
X exit 1; \
X fi
X
Xansi:
X ${MAKE} -f ansi.mk all
X
Xcommon:
X ${MAKE} -f common.mk all
X
X${WINNERS}:
X - at if [ ${USE} = common ]; then \
X ${MAKE} -f common.mk $@; \
X elif [ ${USE} = common ]; then \
X ${MAKE} -f ansi.mk $@; \
X else \
X echo "USE not correctly set in makefile"; \
X exit 1;\
X fi
X
Xclean:
X ${MAKE} -f ansi.mk clean
X ${MAKE} -f common.mk clean
Xclobber:
X ${MAKE} -f ansi.mk clobber
X ${MAKE} -f common.mk clobber
Xnuke: clobber
X ${MAKE} -f ansi.mk nuke
X ${MAKE} -f common.mk nuke
Xinstall:
X ${MAKE} -f ansi.mk install
X ${MAKE} -f common.mk install
//E*O*F Makefile//
echo x - ansi.mk
sed -e 's/^X//' > "ansi.mk" << '//E*O*F ansi.mk//'
X# %W% %G% %U%
X#
X# 1990 makefile
X
XSHELL=/bin/sh
X
X# flags for ANSI compiles
X#
X# These flags are setup for gcc, change as/if needed
X#
XPEDANTIC=-pedantic
XCFLAGS=-O -ansi
XCHMOD=chmod
XCC=gcc
XCP=cp
XRM=rm
XLN=ln
X
X# winners that may be ok to compile with ANSI
X#
XWINNERS=cmills pjr westley stig tbr dg baruch jaw scjones
X
Xall: ${WINNERS}
X
Xansi: all
X
Xcommon:
X @echo "wrong makefile, use common.mk"
X exit 1
X
Xcmills: cmills.c
X ${CC} ${CFLAGS} -DM=500 -DN=52 -DX="srand((int)time(0L))" -DV=void \
X -o cmills cmills.c
X
Xpjr: pjr.c
X ${CC} ${CFLAGS} pjr.c -o pjr
X
Xwestley: westley.c
X ${CC} ${CFLAGS} westley.c -o westley
X
Xstig: stig.c stig.ksh
X @echo "run the Korn shell, and source stig.ksh"
X @echo "or read stig.hint and create your own aliases"
X
Xscjones: scjones.c
X ${CC} ${CFLAGS} scjones.c -o scjones
X
Xtbr: tbr.c
X ${CC} ${CFLAGS} tbr.c -o tbr
X
Xdg: dg.c
X ${CC} ${CFLAGS} dg.c -o dg
X # compile with the following if you don't have index()
X #${CC} ${CFLAGS} dg.c -Dindex=strchr -o dg
X
Xdds: dds.c LANDER.BAS
X ${CC} ${CFLAGS} dds.c -o dds
X
Xtheorem: theorem.c
X ${CC} ${CFLAGS} theorem.c -o theorem
X ${RM} -f sorter.c
X -./theorem -r 0 0 0 0 < theorem.c > sorter.c
X ${CC} ${CFLAGS} sorter.c -o sorter
X ${RM} -f fibonacci.c
X -./sorter 0 0 0 0 < theorem.c > fibonacci.c
X ${CC} ${CFLAGS} fibonacci.c -o fibonacci
X
Xbaruch: baruch.c
X ${CC} ${CFLAGS} baruch.c -o baruch
X
Xjaw: jaw.c shark.sh
X ${RM} -f ./zcat ./atob ./jaw
X ${CC} ${CFLAGS} ${PEDANTIC} jaw.c -o zcat
X ${LN} zcat atob
X echo 'PATH=;export PATH;atob|zcat' > jaw
X ${CHMOD} 0555 ./jaw
X
Xclean:
X ${RM} -f *.o a.out core
Xclobber: clean
X ${RM} -f ${WINNERS} sorter.c sorter
X ${RM} -f fibonacci.c fibonacci atob zcat
Xnuke: clobber
X @true
Xinstall: all
X cat ${WINNERS} > /dev/null
//E*O*F ansi.mk//
echo x - common.mk
sed -e 's/^X//' > "common.mk" << '//E*O*F common.mk//'
X# %W% %G% %U%
X#
X# 1990 makefile
X
XSHELL=/bin/sh
XCHMOD=chmod
XCC=gcc
XCP=cp
XRM=rm
XSED=sed
XLN=ln
X
X# flags for common K&R compiles
X#
XCFLAGS=-O
XCC=cc
X
X# winners that may be ok to compile with common K&R
X#
XWINNERS=cmills pjr westley tbr dg dds theorem baruch jaw scjones
X
Xall: ${WINNERS}
X
Xansi:
X @echo "wrong makefile, use ansi.mk"
X exit 1
X
Xcommon: all
X
Xcmills: cmills.c
X ${CC} ${CFLAGS} -DM=500 -DN=52 -DX="srand((int)time(0L))" -DV=int \
X -o cmills cmills.c
X
Xpjr: pjr.c
X ${CC} ${CFLAGS} pjr.c -o pjr
X
Xwestley: westley.alt.c
X ${CC} ${CFLAGS} westley.alt.c -o westley
X
Xwestley.alt.c: westley.c
X ${RM} -f westley.alt.c
X -${SED} -e 's/signed//' -e 's/1s/1/g' -e 's/^ #/#/' \
X westley.c > westley.alt.c
X
Xstig: stig.c stig.ksh
X @echo "run the Korn shell, and source stig.ksh"
X @echo "or read stig.hint and create your own aliases"
X
Xtbr: tbr.c
X ${CC} ${CFLAGS} tbr.c -o tbr
X
Xdg: dg.c
X ${CC} ${CFLAGS} dg.c -o dg
X # compile with the following if you don't have index()
X #${CC} ${CFLAGS} dg.c -Dindex=strchr -o dg
X
Xdds: dds.c LANDER.BAS
X ${CC} ${CFLAGS} dds.c -o dds
X
Xtheorem: theorem.c
X ${CC} ${CFLAGS} theorem.c -o theorem
X ${RM} -f sorter.c
X -./theorem -r 0 0 0 0 < theorem.c > sorter.c
X ${CC} ${CFLAGS} sorter.c -o sorter
X ${RM} -f fibonacci.c
X -./sorter 0 0 0 0 < theorem.c > fibonacci.c
X ${CC} ${CFLAGS} fibonacci.c -o fibonacci
X
Xbaruch: baruch.c
X ${CC} ${CFLAGS} baruch.c -o baruch
X
Xjaw: jaw.c
X ${RM} -f ./zcat ./atob ./jaw
X ${CC} ${CFLAGS} jaw.c -o zcat
X ${LN} zcat atob
X echo 'PATH=;export PATH;atob|zcat' > jaw
X ${CHMOD} 0555 ./jaw
X
Xscjones: scjones.alt.c stdlib.h
X ${CC} ${CFLAGS} -I. scjones.alt.c -o scjones
X
X# NOTE: scjones.alt.c is just a de-ANSI-fied scjones.c for example only
X#
Xscjones.alt.c: scjones.c
X ${RM} -f scjones.alt.c
X -${SED} -e 's#??/#\\#g' -e 's/??=/#/g' -e 's/??(/[/g' -e 's/??)/]/g' \
X -e "s/??'/^/g" -e 's/??</{/g' -e 's/??!/|/g' -e 's/??>/}/g' \
X -e 's/??-/~/g' scjones.c > scjones.alt.c
X
Xstdlib.h:
X ${RM} -f stdlib.h
X echo "#define EXIT_SUCCESS 0" >stdlib.h
X echo "#define EXIT_FAILURE 1" >>stdlib.h
X echo "void exit(); /* may need to be int on some systems */" >>stdlib.h
X
Xclean:
X rm -f *.o a.out core
Xclobber: clean
X ${RM} -f ${WINNERS} sorter.c sorter westley.alt.c stdlib.h
X ${RM} -f fibonacci.c fibonacci atob zcat scjonds.alt.c
Xnuke: clobber
X @true
Xinstall: all
X cat ${WINNERS} > /dev/null
//E*O*F common.mk//
echo x - baruch.c
sed -e 's/^X//' > "baruch.c" << '//E*O*F baruch.c//'
Xv,i,j,k,l,s,a[99];
Xmain()
X{
X for(scanf("%d",&s);*a-s;v=a[j*=v]-a[i],k=i<s,j+=(v=j<s&&(!k&&!!printf(2
X+"\n\n%c"-(!l<<!j)," #Q"[l^v?(l^j)&1:2])&&++l||a[i]<s&&v&&v-i+j&&v+i-j))&&!(l%=
Xs),v||(i==j?a[i+=k]=0:++a[i])>=s*k&&++a[--i])
X ;
X}
//E*O*F baruch.c//
echo x - cmills.c
sed -e 's/^X//' > "cmills.c" << '//E*O*F cmills.c//'
X#include<stdio.h>
X#include<time.h>
X#define S(q)B(*e=0),q,p);
X#define W(w)if((w)<22)v= -v;else v-=10;else
X#define F for(r=d;r<d+N;
X#define H(v,g)v=h(v,*g++= *r++),*g=0;
X#define B(n)b(l,n),(V)printf(l
XV
Xexit();char*g,c[M],d[N],q[N],p[N],*e,*r=d+N,l[M],*t="??",*k,*m="DEATHISDSev2oin
Xpohae3ttsluuln4a?uibfe 5l\0rtlfrb6 ?a?el:e7$!n\0?e t8%ccp\0.%s9deelc.s T.@?-t.\
Xt<J /\0=a\nP=Q Sex \0l KW Sin a$\0ane-lay% ge#-slediefuk ar r$via-:o ?+}:r? n \
X0:) ee%lone 1-esy666!-~v\n.!^`'~@#\0\np~===:=q";b(o,n)char*o;{for(k=n+m;*o++=*k;k+=9);}int
Xy=M*2,v,x,s,f,j,o;u(s){B(s));if(!gets(l))exit(0);return(o=
X*l)=='y'||o=='Y'||o!='n'&&o!='N'&&u(s);}h(v,m){for(k=c;*k!='J';)if(m==*k++)break;m=k-c;if(v<0)W(v=m-v)
Xif(m==1)W(v+=11)
Xv+=m;return
Xv;}main(w,z)char**z;{b(c,2)*X;for(--w&&(y=atoi(1[z]));y>1;){if(r-d>N*3/4){B(8));F++r)*r=c[(r-d)%13];F)w=
X*(g=d+rand()%N),*g=
X*r,*r++=w;r=d;}for(;;){B(3),y);if(!gets(l)||(w=atoi(l))<1)exit(0);if(w&1||w>M||w>y)B(1),y<M?y:M);else
Xbreak;}y-=w,s=f=j=x=v=0,g=q,e=p;H(x,g)H(x,g)H(v,e)H(v,e)*t=
X*q;S(t)*q=='A'&&y>=w/2&&u(5)&&(y+=(3*(h(0,1[q])==10)-1)*w/2);if(x==-21)goto
X_;if(v==-21){y+=w/2;goto
X_;}while(x>-17&&x<17)H(x,g)while((v==20||*p==-1[e])&&y>=w&&u(6)){y-=w;++s;for(g=e++;2[g]=
X*g,g!=p;)--g;*g++=
X*e;*g=' ';i:v=h(h(0,*p),*e++=
X*r++);S(t)if(*p=='A'&&-1[e]!=
X*p)goto
X_;}if(f=y>=w&&u(7))y-=w,H(v,e)while(!f&&v<22&&u(4)){H(v,e)if(v<22)S(t)}_:x<0&&(x=
X-x);v<0&&(v=
X-v);if(v<22)if(v==x)j+=w*++f;else
Xif(x>21||v>x)j+=w*2*++f;if(s--){*e++=' ';*e++=
X*p;*e=0;for(e=p;*e=2[e];)e++;goto
Xi;}y+=j;S(q)};}
//E*O*F cmills.c//
echo x - dds.c
sed -e 's/^X//' > "dds.c" << '//E*O*F dds.c//'
X#define O(b,f,u,s,c,a)b(){int o=f();switch(*p++){X u:_ o s b();X c:_ o a b();default:p--;_ o;}}
X#define t(e,d,_,C)X e:f=fopen(B+d,_);C;fclose(f)
X#define U(y,z)while(p=Q(s,y))*p++=z,*p=' '
X#define N for(i=0;i<11*R;i++)m[i]&&
X#define I "%d %s\n",i,m[i]
X#define X ;break;case
X#define _ return
X#define R 999
Xtypedef char*A;int*C,E[R],L[R],M[R],P[R],l,i,j;char B[R],F[2];A m[12*R],malloc
X(),p,q,x,y,z,s,d,f,fopen();A Q(s,o)A s,o;{for(x=s;*x;x++){for(y=x,z=o;*z&&*y==
X*z;y++)z++;if(z>o&&!*z)_ x;}_ 0;}main(){m[11*R]="E";while(puts("Ok"),gets(B)
X)switch(*B){X'R':C=E;l=1;for(i=0;i<R;P[i++]=0);while(l){while(!(s=m[l]))l++;if
X(!Q(s,"\"")){U("<>",'#');U("<=",'$');U(">=",'!');}d=B;while(*F=*s){*s=='"'&&j
X++;if(j&1||!Q(" \t",F))*d++=*s;s++;}*d--=j=0;if(B[1]!='=')switch(*B){X'E':l=-1
XX'R':B[2]!='M'&&(l=*--C)X'I':B[1]=='N'?gets(p=B),P[*d]=S():(*(q=Q(B,"TH"))=0,p
X=B+2,S()&&(p=q+4,l=S()-1))X'P':B[5]=='"'?*d=0,puts(B+6):(p=B+5,printf("%d\n",S
X()))X'G':p=B+4,B[2]=='S'&&(*C++=l,p++),l=S()-1 X'F':*(q=Q(B,"TO"))=0;p=B+5;P[i
X=B[3]]=S();p=q+2;M[i]=S();L[i]=l X'N':++P[*d]<=M[*d]&&(l=L[*d]);}else p=B+2,P[
X*B]=S();l++;}X'L':N printf(I)X'N':N free(m[i]),m[i]=0 X'B':_ 0 t('S',5,"w",N
Xfprintf(f,I))t('O',4,"r",while(fgets(B,R,f))(*Q(B,"\n")=0,G()))X 0:default:G()
X;}_ 0;}G(){l=atoi(B);m[l]&&free(m[l]);(p=Q(B," "))?strcpy(m[l]=malloc(strlen(p
X)),p+1):(m[l]=0,0);}O(S,J,'=',==,'#',!=)O(J,K,'<',<,'>',>)O(K,V,'$',<=,'!',>=)
XO(V,W,'+',+,'-',-)O(W,Y,'*',*,'/',/)Y(){int o;_*p=='-'?p++,-Y():*p>='0'&&*p<=
X'9'?strtol(p,&p,0):*p=='('?p++,o=S(),p++,o:P[*p++];}
//E*O*F dds.c//
echo x - dg.c
sed -e 's/^X//' > "dg.c" << '//E*O*F dg.c//'
X#include <stdio.h>
X
X#define d define
X
X#d b12(x) 12 x
X#d a13(x) x 13
X#d a16(x) x 16
X#d a32(x) x 32
X#d acb(x) x]
X#d acc(x) x}
X#d aco(x) x:
X#d bco(x) :x
X#d acp(x) x)
X#d bef(x) EOF x
X#d aeq(x) x=
X#d afo(x) x for
X#d age(x) x fgetc
X#d asi(x) x stdin
X#d aso(x) x stdout
X#d bgt(x) >x
X#d ai(x) x i
X#d aj(x) x j
X#d al(x) x l
X#d ami(x) x-
X#d bne(x) !=x
X#d aob(x) x[
X#d aop(x) x(
X#d apl(x) x+
X#d bpu(x) fputc x
X#d bqm(x) ?x
X#d aqm(x) x?
X#d aqu(x) x'
X#d ase(x) x;
X#d awh(x) x while
X#d axo(x) x^
X#d a0(x) x 0
X#d b13(x) 13 x
X#d b16(x) 16 x
X#d b19(x) 19 x
X#d b48(x) 48 x
X#d a64(x) x 64
X#d b66(x) 66 x
X#d bcb(x) ]x
X#d bch(x) char x
X#d bcm(x) ,x
X#d acm(x) x,
X#d bcp(x) )x
X#d beq(x) =x
X#d bex(x) extern x
X#d bi(x) i x
X#d bin(x) int x
X#d bix(x) index x
X#d bj(x) j x
X#d bl(x) l x
X#d alt(x) x<
X#d bma(x) main x
X#d bob(x) [x
X#d boc(x) {x
X#d bop(x) (x
X#d bpl(x) +x
X#d app(x) x++
X#d bqu(x) 'x
X#d bse(x) ;x
X#d bst(x) *x
X
Xbma(acp(bop(app(bcp(ai(boc(ase(bch(a16(bl(alt(bob(ai(b66(ase(bcb(a0(bcm(aeq(bst
X(acb(bj(a64(bse(aob(bin(al(bi(aeq(bse(ai(bex(aop(bch(afo(bst(ase(bix(()))))))))
X)))))))))))))))))))))))))))))))
Xbl(ai(bob(aob(bi(al(bcb(aop(beq(apl(b13(a13(bpl(aeq(bop(acb(bl(bob(a32(bi(bpl(a
Xpl(b16(bcb(ai(beq(b19(aob(bpl(bop(l))))))))))))))))))))))))))))))
Xbpl(acp(b48(acp(asi(bcb(aop(beq(age(bop(aeq(bi(ai(bgt(aop(b12(aop(bqm(awh(b12(a
Xse(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A))))))))))))))))))))))))))))))
Xbne(acc(bef(ase(bcp(acp(aso(bpu(acm(ai(bop(aco(bop(acb(bj(al(beq(ami(bix(aj(axo
X(bop(a16(aob(bl(al(aqm(bcm(acp(acp(i))))))))))))))))))))))))))))))
//E*O*F dg.c//
echo x - jaw.c
sed -e 's/^X//' > "jaw.c" << '//E*O*F jaw.c//'
X#define C char
X#define F X,perror("oops"),1
X#define G getchar()
X#define I ;if(
X#define P putchar
X#define Q 256
X#define W ;while(
X#define X return 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[69001];b(g){k=4 W g<k)y(P((C)(w>>--k*8)&255));w=0;}C D[Q*Q],h
X[Q*Q];main(g,V)C**V;{I**V-97)X,a()W G-10)W(g=G)+1&&g-'x')if(g-10){I
X4<k)b(0)I g>32&g<'v')w=w*85+g-33,++k;else{I
Xg-'z'|k)F;w=0;k=5;}}W G-78)I scanf("%ld%lx E%lx S%lx R%lx ",&M,&N,&c,&s,&r)-5)F
XI M){b(g=3-(M-1&3))W g--)y(0);}I(M-N|c-o|s-m|r-f)&4294967295)F;X;}long
Xg(){C*p I m<f&n<k&&(m=(1L<<++n)-1)||O>=S){O=0;S=fread(D,1,n,stdin)*8 I
XS<8)X-1;S-=n-1;}p=D+O/8;q=O&7;O+=n;X,(1<<8-q)-1&*p>>q|m&((15<n+q)*p[2]*Q|p[1]&
X255)<<8-q;}a(){C*p=D+Q;G;G;k=G;e=k>>7&1;k&=31 I k>16)F;w=Q
XW w--)t[w]=0,h[w]=w;n=8;f=Q+e;i=o=w=g()I o<0)X,1;P(i)W(w=g())+1){I
Xw==Q&e){W w--)t[w]=0;m=n=8;f=Q I(w=g())<0)X;}c=w
XI w>=f)*p++=i,w=o W w>=Q)*p++=h[w],w=t[w];P(i=h[w])W
Xp>D+Q)P(*--p)I(w=f)<1L<<k)t[w]=o,h[f++]=i;o=c;}X;}
//E*O*F jaw.c//
echo x - pjr.c
sed -e 's/^X//' > "pjr.c" << '//E*O*F pjr.c//'
X#include <stdio.h>
X#define A(a) G a();
X#define B(a) G (*a)();
X#define C(a,b) G a() { printf(b); return X; }
Xtypedef struct F G;A(a)A(b)A(c)A(d)A(e)A(f)A(g)A(h)A(i)A(j)A(k)A(l)A(m)A(n)A(
Xo)A(p)A(q)A(r)A(s)A(t)A(u)A(v)A(w)A(x)A(y)A(z)A(S)A(N)void Q();struct F{B(a)B
X(b)B(c)B(d)B(e)B(f)B(g)B(h)B(i)B(j)B(k)B(l)B(m)B(n)B(o)B(p)B(q)B(r)B(s)B(t)B(
Xu)B(v)B(w)B(x)B(y)B(z)B(S)B(N)void(*Q)();}X={a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,
Xq,r,s,t,u,v,w,x,y,z,S,N,Q};C(a,"z")C(b,"y")C(c,"x")C(d,"w")C(e,"v")C(f,"u")C(
Xg,"t")C(h,"s")C(i,"r")C(j,"q")C(k,"p")C(l,"o")C(m,"n")C(n,"m")C(o,"l")C(p,"k"
X)C(q,"j")C(r,"i")C(s,"h")C(t,"g")C(u,"f")C(v,"e")C(w,"d")C(x,"c")C(y,"b")C(z,
X"a")C(S," ")C(N,"\n") void Q(){}main(){X=g().s().v().S().j().f().r().x().p().
XS().y().i().l().d().m().S().u().l().c().S().q().f().n().k().v().w().S().l().e
X().v().i().S().g().s().v().S().o().z().a().b().S().w().l().t().N();}
//E*O*F pjr.c//
echo x - scjones.c
sed -e 's/^X//' > "scjones.c" << '//E*O*F scjones.c//'
Xchar*a??(??)=??<
X"??=include<stdio.h>",
X"??=include<stdlib.h>",
X"??=define o stdout",
X"??=define b break;case",
X"??=define s(p)fputs(p,o);",
X"??=define c(p)fputc(p,o);",
X"void t(p,f)char*p;??<f&&c('??/"')",
X"for(;;p++)??<switch(*p)??<case 0:f&&",
X"s(??/"??/??/??/",??/")c('??/??/n')return;case",
X"'??=':s(??/"???/??/?=??/")b'??<':s(??/"???/??/?<??/")",
X"b'??>':s(??/"???/??/?>??/")b'??(':s(??/"???/??/?(??/")b'??)'",
X":s(??/"???/??/?)??/")b'??/??/??/??/':f&&s(??/"???/??/?/??/")",
X"s(??/"???/??/?/??/")b'??/??/n':if(f)s(??/"???/??/?/n??/")",
X"else case'??/"':if(f)s(??/"???/??/?/??/??/??/"??/")",
X"else default:c(*p)??>??>??>main()??<char**p",
X";t(??/"char*a??(??)=??<??/",0);for(p=a;*p",
X";p++)t(*p,1);t(??/"0??>;??/",0);for(p=a",
X";*p;p++)t(*p,0);exit(!ferror(o)&&",
X"!fclose(o)?EXIT_SUCCESS",
X":EXIT_FAILURE);",
X"/*NOTREACHED*/",
X"??>",
X0??>;
X??=include<stdio.h>
X??=include<stdlib.h>
X??=define o stdout
X??=define b break;case
X??=define s(p)fputs(p,o);
X??=define c(p)fputc(p,o);
Xvoid t(p,f)char*p;??<f&&c('"')
Xfor(;;p++)??<switch(*p)??<case 0:f&&
Xs("??/",")c('??/n')return;case
X'??=':s("???/?=")b'??<':s("???/?<")
Xb'??>':s("???/?>")b'??(':s("???/?(")b'??)'
X:s("???/?)")b'??/??/':f&&s("???/?/")
Xs("???/?/")b'??/n':if(f)s("???/?/n")
Xelse case'"':if(f)s("???/?/??/"")
Xelse default:c(*p)??>??>??>main()??<char**p
X;t("char*a??(??)=??<",0);for(p=a;*p
X;p++)t(*p,1);t("0??>;",0);for(p=a
X;*p;p++)t(*p,0);exit(!ferror(o)&&
X!fclose(o)?EXIT_SUCCESS
X:EXIT_FAILURE);
X/*NOTREACHED*/
X??>
//E*O*F scjones.c//
echo x - stig.c
sed -e 's/^X//' > "stig.c" << '//E*O*F stig.c//'
Xc
//E*O*F stig.c//
echo x - tbr.c
sed -e 's/^X//' > "tbr.c" << '//E*O*F tbr.c//'
X
X#define D ,close(
X
Xchar *c,q [512 ],m[ 256
X],*v[ 99], **u, *i[3];int f[2],p;main (){for
X (m[m [60]= m[62 ]=32 ]=m[* m=124 [m]= 9]=6;
X e(-8) ,gets (1+( c=q) )|| exit (0); r(0,0)
X )for( ;*++ c;); }r(t, o){ *i=i [2]= 0;for
X (u=v +98 ;m[*--c] ^9;m [*c] &32 ?i[*c
X &2]= *u,u- v^98 &&++u:
X
X 3 )if(!m[*c]){for(*++c=0;!m[*--c];);
X * --u= ++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[
X 1 ]:
X 4 ,(p=fork())?e(p),o?r(o,0)D o)D*f):
X 1 ,wait(0):(o?dup2(*f,0)D*f)D o):*i?
X 5 D 0),e(open(*i,0)):
X 9 ,t?dup2(t,1)D t):i[
X 2 ]?
X 6 D 1),e(creat(i[2],438)):
X 5 ,e(execvp(*u,u))):e(chdir(u[1])*2):
X 3 ;}e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||exit(1):
X 5 ;}
//E*O*F tbr.c//
echo x - theorem.c
sed -e 's/^X//' > "theorem.c" << '//E*O*F theorem.c//'
X#include <stdio.h>
X#include <math.h>
X#define X
X#define Y {}
X#define C }
X#define o {
X#undef main
Xchar m[500][99],v[99],R;
Xint*a,b,n,i,j,W,A;
Xfloat Q,G,D,M,T,B,O,U,V,N,y,e();
XP(g,R,u)float*g,R,u;{int c;for(*g=1,c=u;c--;*g*=R);}
XX
XK(g,R,u)float*g,u;char R;
Xo
Xif(R=='+')*g+=u;
Xif(R=='-')*g-=u;
Xif(R=='*')*g*=u;
Xif(R=='/')*g/=u;
Xif(R=='^')P(g,*g,u);
XC
Xw(g,R,u)float*g,u;char R;
X/**/{int b,f;A=atoi(*++a);b=atoi(*++a);while((f=A+b)<15000){printf("%d\n",f);A=b;b=f;}}
Xmain(A,a)int A;char*a[];
Xo o
Xif(!strcmp(*++a,"-r"))S();
XD=atof(*++a);
XT=atof(*++a);
XB=atof(*++a);
XM=atof(*(4+(a-=3)));
XC
Xwhile(D<T)
Xo
XU=e((G=B/2,*a),D,M,a);
XV=e(*a,Q=D+G,M+G*U,a);
X/*/
Xz;/*/
XN=2*e(*a,Q,M+G*V,a);
XM+=B*V/3+B*N/6+B*e(*a,D+=B,M+G*N,a)/6+G*U/3;
Xprintf("%f %f\n",D,M);
XC
Xwhile(T=0)
X;
XW=D=1;
X;
Xwhile(W!=1)
Xo o
Xstrcpy(j+m,v);
Xo
Xif((j-=W)<=W)break;
Xstrcpy(j+m,m+j-W);
XC
Xwhile(strcmp(m+j-W,v)>0)
Xj=i;
Xstrcpy(v,i+m);
XC
Xfor(i=(W/=3)-1;++i<n;)
X;
XC
Xdo
X;
Xwhile(0);
Xfor(W=1;(W=W*3+1)<n;);
XC
Xfloat e(f,D,M,a)char*f,*a[];float D,M;
Xo
X#define main L
XO=0;
XR='+';
Xfor(;*f;f++)
Xif(*f=='y')K(&O,R,M);
Xelse if((*f>='0')&&(*f<='9'))K(&O,R,(float)*f-'0');
Xelse if(*f=='x')K(&O,R,D);
Xelse if(1)R=*f;
Xif(1);
Xreturn O;
Xfor(j=0;j<n;puts(j++[m]));
Xe("",O,&O,a);
Xn=j-(O=1);
Xwhile(gets(j++[m]));
Xif(!strcmp(*++a,"-r"))S();
XC
X/**/main(A,a)int A;char*a[];
XY
XS(){while(gets(b++[m]));for(b--;b--;puts(b[m]));}
Xchar*f,m[500][99],R,v[99];
Xint b,W,n,i,j,z;
Xfloat Q,G,D,M,T,O,B,U,V,N,e();
X#define Y
X#define X {}
X#define o }
X#define C {
X#include <stdio.h>
X#include <math.h>
//E*O*F theorem.c//
echo x - westley.c
sed -e 's/^X//' > "westley.c" << '//E*O*F westley.c//'
Xchar*lie;
X
X double time, me= !0XFACE,
X
X not; int rested, get, out;
X
X main(ly, die) char ly, **die ;{
X
X signed char lotte,
X
X
Xdear; (char)lotte--;
X
X for(get= !me;; not){
X
X 1 - out & out ;lie;{
X
X char lotte, my= dear,
X
X **let= !!me *!not+ ++die;
X
X (char*)(lie=
X
X
X"The gloves are OFF this time, I detest you, snot\n\0sed GEEK!");
X
X do {not= *lie++ & 0xF00L* !me;
X
X #define love (char*)lie -
X
X love 1s *!(not= atoi(let
X
X [get -me?
X
X (char)lotte-
X
X
X(char)lotte: my- *love -
X
X 'I' - *love - 'U' -
X
X 'I' - (long) - 4 - 'U' ])- !!
X
X (time =out= 'a'));} while( my - dear
X
X && 'I'-1l -get- 'a'); break;}}
X
X (char)*lie++;
X
X
X(char)*lie++, (char)*lie++; hell:0, (char)*lie;
X
X get *out* (short)ly -0-'R'- get- 'a'^rested;
X
X do {auto*eroticism,
X
X that; puts(*( out
X
X - 'c'
X
X-('P'-'S') +die+ -2 ));}while(!"you're at it");
X
X
Xfor (*((char*)&lotte)^=
X
X (char)lotte; (love ly) [(char)++lotte+
X
X !!0xBABE];){ if ('I' -lie[ 2 +(char)lotte]){ 'I'-1l ***die; }
X
X else{ if ('I' * get *out* ('I'-1l **die[ 2 ])) *((char*)&lotte) -=
X
X '4' - ('I'-1l); not; for(get=!
X
X
Xget; !out; (char)*lie & 0xD0- !not) return!!
X
X (char)lotte;}
X
X
X(char)lotte;
X
X do{ not* putchar(lie [out
X
X *!not* !!me +(char)lotte]);
X
X not; for(;!'a';);}while(
X
X love (char*)lie);{
X
X
Xregister this; switch( (char)lie
X
X [(char)lotte] -1s *!out) {
X
X char*les, get= 0xFF, my; case' ':
X
X *((char*)&lotte) += 15; !not +(char)*lie*'s';
X
X this +1s+ not; default: 0xF +(char*)lie;}}}
X
X get - !out;
X
X if (not--)
X
X goto hell;
X
X exit( (char)lotte);}
//E*O*F westley.c//
echo x - baruch.hint
sed -e 's/^X//' > "baruch.hint" << '//E*O*F baruch.hint//'
XBest Small Program: <baruch at genius.tau.ac.il> Osovlanski & Nissenbaum
X
X Doron Osovlanski
X CADTECH - CAD/CAM Systems Ltd
X 24 Ben-Yosef st.
X Givat-Shmuel 51905
X Israel
X
X Baruch Nissenbaum BARUCH at TAUNIVM.TAU.AC.IL
X Tel-Aviv University
X The Faculty of Engineering
X Tel-Aviv
X Israel
X
X
XJudges' comments:
X
X Compile. Try:
X
X echo 4 | baruch
X echo 7 | baruch
X
X This program reads an integer between 4 and 99 from the stdin.
X
X NOTE: The original program did not have a newline at the end of
X the file. We added a final newline to the file to make
X unpacking easy.
X
X
XSelected notes from the author:
X
X The goal of this work was to write a program that solves the
X classic n-queen problem, with a board size of up to 99x99, while
X keeping the program as short as possible.
X
X The program finds all possibilities to place N chess queens on
X a NxN chess board so that no queen is in range of any other queen
X (not in the same column row or diagonal). For each solution the
X chess board and the place of the queens is printed to stdout.
X
X
X This program is about as simple and as readable as possible.
X To make things even more simple we used a very limited subset of C:
X
X No pre-processor statements
X Only one, harmless, 'for' statement
X No ifs
X No breaks
X No cases
X No functions
X No gotos
X No structures
X
X In short, it contains no C language that might confuse the
X innocent reader. :-)
X
X
X This program demonstrates the claim that in C, any program
X can be written using a single 'for' statement, as long as it is
X long enough..
X
XThe authors further note:
X
X For PC users:
X In order to compile the program under Turbo-C or MSC, 'int '
X should be inserted at the beginning of the program.
X For better looking results it is recommended to replace the " #Q"
X string with " \261\2".
//E*O*F baruch.hint//
echo x - cmills.hint
sed -e 's/^X//' > "cmills.hint" << '//E*O*F cmills.hint//'
XBest Game: <cmills at wyse.com> Chris Mills
X
X Chris Mills
X Wyse Technology
X 3471 N. 1st St.
X San Jose CA 95134
X USA
X
X
XJudges notes:
X
X Compile notes:
X
X cc -DM=500 -DN=52 -DX="srand((int)time(0L))" -DV=void -o cmills cmills.c
X
X -DM=<max bet allowed>
X -DN=<52 * number of decks used>
X -DX=<how to seed the rand() generator>
X -DV=<void ot int>
X
X Usage: cmills [starting_cash]
X
X
XSelected notes from the author:
X
X This is a blackjack program. It does splits, doubling down,
X insurance, etc.
X
X As best I can figure, it should be ANSI-compliant, as well as
X portable to BSD & sysV (as well as the irritating compiler I
X was using which assumes x=*p++ means x*=p++!). It is
X reasonably robust in its error handling---it won't let you
X split, double, etc. unless you actually have the cash, etc. To
X terminate the program, hit EOF or type 0 or a negative number
X for you wager.
X
X The way it deals with splits is particularly cool (IMHO). You
X can split many times, and it will show all hands as they are
X played.
//E*O*F cmills.hint//
echo x - dds.hint
sed -e 's/^X//' > "dds.hint" << '//E*O*F dds.hint//'
XBest Language Tool: <dds at cc.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 Compile and run. Give the following lines as input:
X
X OLD LANDER.BAS
X RUN
X
X Be sure not to run out of fuel!
X
X
XSelected notes from the author:
X
X This is the DDS-BASIC Interpreter (Version 1.00).
X
X Immediate commands:
X
X RUN LIST NEW OLD filename
X BYE SAVE filename
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 (ranked by precedence):
X
X Bracketed expressions
X number (leading 0 for octal, 0x for hex, else decimal), variable
X Unary -
X * /
X + -
X = <>
X > <
X <= >=
X (* and + are also used for boolean AND and boolean OR)
X Boolean expressions evaluate to 0 for false and 1 for true
X
X Editing:
X
X - Line editor using line re-entry.
X - A line number with nothing following it, deletes the line.
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 between the OLD or SAVE command and
X the filename.
X - ALL INPUT MUST BE UPPERCASE.
X
X Limits:
X
X Line numbers 1-10000
X Line length 999 characters
X FOR nesting 26
X GOSUB 999 levels
X Program Dynamically allocated
X Expressions -32768 - 32767 for 16 bit machines,
X -2147483648 - 2147483647 for 32 bit machines
X
X Error checking / error reports:
X
X No error checking is performed.
X The message `core dumped' signifies a syntax or semantic error.
X
X Hosting Environment:
X
X ANSI C, traditional K&R C or OSF ANDF
X ASCII or EBCIDIC character set
X 48K bytes memory
X
X The Speed of DDS-BASIC Interpreter (Version 1.00). relative to
X Microsoft Advanced BASIC 3.31 is Approximately 60%.
X
X The code size could be further reduced by doing ugly things like
X not declaring the return type of functions, not freeing memory,
X #defining define, and joining lines. In its present 1536 character
X form the program is reasonably portable (it may fail to run in a
X tagged object architecture) and nicely formatted (it fits in an
X 80*25 screen).
//E*O*F dds.hint//
echo x - dg.hint
sed -e 's/^X//' > "dg.hint" << '//E*O*F dg.hint//'
XBest Abuse of the C Preprocessor: <harvard!xait!pallio!dg> David Goodenough
X
X David Goodenough
X anonymous organization
X 541 Commonwealth Ave,
X Newton, MA 02159
X USA
X
XJudges' comments:
X
X Compile and run. Try:
X
X echo "to C or not to C" | dg
X
X Some C preprocessors get confused about single quotes in certain cases.
X In particular, the following source line:
X
X Cb12(ase(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A))))))))))))))))))))))))))))))
X
X may need to be changed to:
X
X Cb12(ase(bco(acp(bi(acp(bcp(acp(bpl('A'))))))))))))))))))))))))))))
X
X if your C preprocessor botches single quotes in cpp expansions.
X
X Systems that use strchr() instead of index() (e.g., SVR3) should
X compile with -Dindex=strchr.
X
XSelected notes from the author:
X
X If my preprocessor could hack it, I could write this as one single
X line rather than 4, but when I do that I get a complaint "defines
X nested too deeply".
X
X Spoiler: (rot13 to read)
X
X Guvf vf nabgure ebg13 wbo (oryvrir vg be abg) - gur #qrsvarf ner n
X abiry jnl bs nqqvat gbxraf: '#qrsvar o12(k) 12 k' zrnaf gung ng
X fbzr cbvag va gur fbhepr n 12 vf sbyybjrq ol gur pbzcerffrq arfgrq
X qrsvarf. Gur o12 trgf gur cerivbhf pbzcerffvba nf na nethzrag, naq
X cercraqf gur 12, guhf znxvat nabgure fgrc va gur erperngvba bs gur
X fbhepr. Gur nkk() qrsvarf qb gur fnzr, ohg nqq gbxraf nsgre.
X
X Nf sbe gur ebg13 nytbevguz, vg eryvrf ba vaqrk() gb svaq vs gur
X punenpgre vf va gur frg N-Mn-m. y[] vf na neenl gung trgf svyyrq
X jvgu:
X
X "abcdefghijklmmmmnopqrstuvwxyzzzzABCDEFGHIJKLMMMMNOPQRSTUVWXYZZZZ"
X
X Vs vaqrk() fnlf gur pune vf va gur nycunorg, gura kbe gur bssfrg
X jvgu 16 gb genafyngr, naq bhgchg, bgurejvfr cnff vg hapunatrq.
//E*O*F dg.hint//
echo x - jaw.hint
sed -e 's/^X//' > "jaw.hint" << '//E*O*F 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! :-)
//E*O*F jaw.hint//
echo x - pjr.hint
sed -e 's/^X//' > "pjr.hint" << '//E*O*F 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
//E*O*F pjr.hint//
echo x - scjones.hint
sed -e 's/^X//' > "scjones.hint" << '//E*O*F 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 ]]
//E*O*F scjones.hint//
echo x - stig.hint
sed -e 's/^X//' > "stig.hint" << '//E*O*F 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.
//E*O*F stig.hint//
echo x - tbr.hint
sed -e 's/^X//' > "tbr.hint" << '//E*O*F 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.
//E*O*F tbr.hint//
echo x - theorem.hint
sed -e 's/^X//' > "theorem.hint" << '//E*O*F 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.
//E*O*F theorem.hint//
echo x - westley.hint
sed -e 's/^X//' > "westley.hint" << '//E*O*F 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...
//E*O*F westley.hint//
echo x - LANDER.BAS
sed -e 's/^X//' > "LANDER.BAS" << '//E*O*F 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."
//E*O*F LANDER.BAS//
echo x - stig.ksh
sed -e 's/^X//' > "stig.ksh" << '//E*O*F stig.ksh//'
Xalias c="cc -E stig.c -Dc='main(){printf(\"N%sested comments allowed.\\n"'",/*/
X*/0*/**/1?"":"o n"'");}'|grep -v '^#'>o.c;cc -o o o.c;o"
//E*O*F stig.ksh//
echo x - shark.sh
sed -e 's/^X//' > "shark.sh" << '//E*O*F 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
//E*O*F shark.sh//
echo Possible errors detected by \'wc\' [hopefully none]:
temp=/tmp/shar$$
trap "rm -f $temp; exit" 0 1 2 3 15
cat > $temp <<\!!!
27 220 1265 README
218 1441 8876 rules
60 231 1318 Makefile
86 259 1710 ansi.mk
104 340 2326 common.mk
8 9 233 baruch.c
33 62 1515 cmills.c
24 70 1536 dds.c
74 223 1531 dg.c
22 65 999 jaw.c
14 37 879 pjr.c
46 66 1474 scjones.c
1 1 2 stig.c
23 80 886 tbr.c
93 133 1511 theorem.c
107 208 1529 westley.c
68 297 1908 baruch.hint
39 161 1054 cmills.hint
94 360 2315 dds.hint
51 246 1726 dg.hint
214 1011 7401 jaw.hint
60 220 1479 pjr.hint
59 382 2466 scjones.hint
56 330 2213 stig.hint
84 553 3890 tbr.hint
90 414 2585 theorem.hint
48 212 1489 westley.hint
71 346 1624 LANDER.BAS
2 14 137 stig.ksh
47 131 1522 shark.sh
1923 8122 59399 total
!!!
wc README rules Makefile ansi.mk common.mk baruch.c cmills.c dds.c dg.c jaw.c \
pjr.c scjones.c stig.c tbr.c theorem.c westley.c baruch.hint cmills.hint \
dds.hint dg.hint jaw.hint pjr.hint scjones.hint stig.hint tbr.hint \
theorem.hint westley.hint LANDER.BAS stig.ksh shark.sh | \
sed 's=[^ ]*/==' | diff -b $temp -
echo unpack long lines in baruch.c
ed baruch.c << '//long baruch.c//'
4,6j
w
q
//long baruch.c//
echo unpack long lines in cmills.c
ed cmills.c << '//long cmills.c//'
9,12j
w
q
//long cmills.c//
echo unpack long lines in dg.c
ed dg.c << '//long dg.c//'
73,74j
71,72j
69,70j
66,68j
w
q
//long dg.c//
echo unpack long lines in stig.ksh
ed stig.ksh << '//long stig.ksh//'
1,2j
w
q
//long stig.ksh//
exit 0
More information about the Comp.unix.wizards
mailing list