Revisit 1990 entries

Although I previously got them to all compile they did not all work. Now
they do except that jaw does not work properly in macOS (I have noticed
something odd in linux too but it appears to work mostly if not
entirely).

Yusuke Endoh pointed out for 1990/theorem that atof() nowadays needs
include stdlib.h so this was added to the file. As well I added the
inclusion of string.h for strcmp(). I also fixed some segfaults in this
entry (even though the judges pointed out that for NULL pointer one
needs the four '0 0 0 0' it still segfaulted under those conditions) so
that everything should work now under both linux and macOS. There were
iirc two parts to this: one the NULL pointer is no longer dereferenced
but also the type being passed to strcmp() was a int * and not a char *.
This prevented 1990/theorem/sorter from working at all (segfault) and as
I recall it there was another segfault I encountered as well.

For 1990/jaw Yusuke Endoh provided a ruby implementation of btoa as it's
not always available in modern systems. Thank you Yusuke!

In 1990/jaw shark.sh had to be modified as well. This had to do with '.'
not being in the default PATH.

As well I had previously made a mistake about btoa versus atob as both
were referenced in 1990/jaw/README.md. I believe I have this correct
now.

Many if not all the README files were modified with various changes
including formatting (like turning them into markdown) and section
titles amongst other things.

I seem to recall I'm missing something here but I can't recall what I
recall :-) so this will have to suffice this time round (maybe it was
the btoa/atob issue that I just remembered and added above but I'm not
sure).
This commit is contained in:
Cody Boone Ferguson committed 2023-03-11 10:07:14 -08:00
1 parent e5ef2978f6
commit 0ae55de0b8
17 files changed
+420 -347

No files matched your search

+35 -35
View File
@@ -18,56 +18,56 @@
### To run ### To run
echo 4 | baruch echo 4 | ./baruch
echo 7 | baruch echo 7 | ./baruch
## Judges' comments ## Judges' comments
This program reads an integer between 4 and 99 from the stdin. This program reads an integer between 4 and 99 from the stdin.
NOTE: The original program did not have a newline at the end of NOTE: The original program did not have a newline at the end of the file. We
the file. We added a final newline to the file to make added a final newline to the file to make unpacking easy.
unpacking easy.
## Author's comments ## Authors' comments
The goal of this work was to write a program that solves the The goal of this work was to write a program that solves the
classic n-queen problem, with a board size of up to 99x99, while classic n-queen problem, with a board size of up to 99x99, while
keeping the program as short as possible. keeping the program as short as possible.
The program finds all possibilities to place N chess queens on The program finds all possibilities to place N chess queens on
a NxN chess board so that no queen is in range of any other queen a NxN chess board so that no queen is in range of any other queen
(not in the same column row or diagonal). For each solution the (not in the same column row or diagonal). For each solution the
chess board and the place of the queens is printed to stdout. chess board and the place of the queens is printed to stdout.
This program is about as simple and as readable as possible. This program is about as simple and as readable as possible.
To make things even more simple we used a very limited subset of C: To make things even more simple we used a very limited subset of C:
No pre-processor statements No pre-processor statements
Only one, harmless, 'for' statement Only one, harmless, 'for' statement
No ifs No ifs
No breaks No breaks
No cases No cases
No functions No functions
No gotos No gotos
No structures No structures
In short, it contains no C language that might confuse the In short, it contains no C language that might confuse the
innocent reader. :-) innocent reader. :-)
This program demonstrates the claim that in C, any program This program demonstrates the claim that in C, any program
can be written using a single 'for' statement, as long as it is can be written using a single 'for' statement, as long as it is
long enough.. long enough..
The authors further note: The authors' further note:
For PC users: For PC users:
In order to compile the program under Turbo-C or MSC, 'int '
should be inserted at the beginning of the program. In order to compile the program under Turbo-C or MSC, 'int '
For better looking results it is recommended to replace the " #Q" should be inserted at the beginning of the program.
string with " \261\2". For better looking results it is recommended to replace the " #Q"
string with " \261\2".
Copyright (c) 1990, Landon Curt Noll & Larry Bassel. Copyright (c) 1990, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is All Rights Reserved. Permission for personal, educational or non-profit use is
+23 -12
View File
@@ -14,6 +14,17 @@
./cmills [starting_cash] ./cmills [starting_cash]
NOTE: we used a patch from Yusuke Endoh to get this to work in modern systems
(it resulted in a bus error otherwise). Thank you Yusuke for your assistance!
### Try:
./cmills 5000
NOTE: this program uses `gets()` so you will likely get a warning under modern
systems.
## Judges' comments ## Judges' comments
Compile notes: Compile notes:
@@ -27,20 +38,20 @@
## Author's comments ## Author's comments
This is a blackjack program. It does splits, doubling down, This is a blackjack program. It does splits, doubling down,
insurance, etc. insurance, etc.
As best I can figure, it should be ANSI-compliant, as well as As best I can figure, it should be ANSI-compliant, as well as
portable to BSD & sysV (as well as the irritating compiler I portable to BSD & sysV (as well as the irritating compiler I
was using which assumes x=*p++ means x*=p++!). It is was using which assumes `x=*p++` means `x*=p++`!). It is
reasonably robust in its error handling---it won't let you reasonably robust in its error handling---it won't let you
split, double, etc. unless you actually have the cash, etc. To split, double, etc. unless you actually have the cash, etc. To
terminate the program, hit EOF or type 0 or a negative number terminate the program, hit EOF or type 0 or a negative number
for you wager. for you wager.
The way it deals with splits is particularly cool (IMHO). You The way it deals with splits is particularly cool (IMHO). You
can split many times, and it will show all hands as they are can split many times, and it will show all hands as they are
played. played.
Copyright (c) 1990, Landon Curt Noll & Larry Bassel. Copyright (c) 1990, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is All Rights Reserved. Permission for personal, educational or non-profit use is
+1 -1
View File
@@ -6,7 +6,7 @@
#define H(v,g)v=h(v,*g++= *r++),*g=0; #define H(v,g)v=h(v,*g++= *r++),*g=0;
#define B(n)b(l,n),(V)printf(l #define B(n)b(l,n),(V)printf(l
V V
exit();char*g,c[M],d[N],q[N],p[N],*e,*r=d+N,l[M],*t="??",*k,*m="DEATHISDSev2oinpohae3ttsluuln4a?uibfe 5l\0rtlfrb6 ?a?el:e7$!n\0?e t8%ccp\0.%s9deelc.s T.@?-t.\t<J /\0=a\nP=Q Sex \0l KW Sin a$\0ane-lay% ge#-slediefuk ar r$via-:o ?+}:r? n \0:) ee%lone 1-esy666!-~v\n.!^`'~@#\0\np~===:=q";b(o,n)char*o;{for(k=n+m;*o++=*k;k+=9);}int exit();char*g,c[M],d[N],q[N],p[N],*e,*r=d+N,l[M],t[]="??",*k,*m="DEATHISDSev2oinpohae3ttsluuln4a?uibfe 5l\0rtlfrb6 ?a?el:e7$!n\0?e t8%ccp\0.%s9deelc.s T.@?-t.\t<J /\0=a\nP=Q Sex \0l KW Sin a$\0ane-lay% ge#-slediefuk ar r$via-:o ?+}:r? n \0:) ee%lone 1-esy666!-~v\n.!^`'~@#\0\np~===:=q";b(o,n)char*o;{for(k=n+m;*o++=*k;k+=9);}int
y=M*2,v,x,s,f,j,o;u(s){B(s));if(!gets(l))exit(0);return(o= y=M*2,v,x,s,f,j,o;u(s){B(s));if(!gets(l))exit(0);return(o=
*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) *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)
if(m==1)W(v+=11) if(m==1)W(v+=11)
-1
View File
@@ -184,7 +184,6 @@ all: data ${TARGET}
supernova deep_magic magic charon pluto supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c ${PROG}: ${PROG}.c
@echo "NOTE: This entry might not compile when using modern compilers."
${CC} ${CFLAGS} $< -o $@ ${LIBS} ${CC} ${CFLAGS} $< -o $@ ${LIBS}
# alternative executable # alternative executable
+39 -32
View File
@@ -11,6 +11,9 @@
make all make all
Modern compilers could not compile this entry but Yusuke Endoh supplied a patch
which lets it compile. Thank you Yusuke!
### To run ### To run
./dds ./dds
@@ -19,31 +22,32 @@
NOTE: this entry uses `gets()` so you might get a warning when compiling and NOTE: this entry uses `gets()` so you might get a warning when compiling and
running this entry. running this entry.
### Try:
## Judges' comments Give the following lines as input:
Give the following lines as input:
OLD LANDER.BAS OLD LANDER.BAS
RUN RUN
Be sure not to run out of fuel! NOTE: this is case sensitive.
Modern compilers could not compile this entry but Yusuke Endoh supplied a patch ## Judges' comments
which lets it compile. Thank you Yusuke!
Be sure not to run out of fuel!
## Author's comments ## Author's comments
This is the DDS-BASIC Interpreter (Version 1.00). This is the DDS-BASIC Interpreter (Version 1.00).
Immediate commands: Immediate commands:
RUN LIST NEW OLD filename RUN LIST NEW OLD filename
BYE SAVE filename BYE SAVE filename
Program commands: Program commands:
variable names a to z variables initialized to 0 on RUN variable names a to z variables initialized to 0 on RUN
FOR var = exp TO exp NEXT variable FOR var = exp TO exp NEXT variable
@@ -53,7 +57,7 @@ running this entry.
PRINT exp var = exp PRINT exp var = exp
REM any text END REM any text END
Expressions (ranked by precedence): Expressions (ranked by precedence):
Bracketed expressions Bracketed expressions
number (leading 0 for octal, 0x for hex, else decimal), variable number (leading 0 for octal, 0x for hex, else decimal), variable
@@ -66,20 +70,21 @@ running this entry.
(* and + are also used for boolean AND and boolean OR) (* and + are also used for boolean AND and boolean OR)
Boolean expressions evaluate to 0 for false and 1 for true Boolean expressions evaluate to 0 for false and 1 for true
Editing: Editing:
- Line editor using line re-entry. - Line editor using line re-entry.
- A line number with nothing following it, deletes the line. - A line number with nothing following it, deletes the line.
Input format: Input format:
- Free format positioning of tokens on the line. - Free format positioning of tokens on the line.
- No space is allowed before the line number. - No space is allowed before the line number.
- Exactly one space is needed between the OLD or SAVE command and - Exactly one space is needed between the OLD or SAVE command and
the filename. the filename.
- ALL INPUT MUST BE UPPERCASE. - ALL INPUT MUST BE UPPERCASE.
Limits:
Limits:
Line numbers 1-10000 Line numbers 1-10000
Line length 999 characters Line length 999 characters
@@ -89,26 +94,28 @@ running this entry.
Expressions -32768 - 32767 for 16 bit machines, Expressions -32768 - 32767 for 16 bit machines,
-2147483648 - 2147483647 for 32 bit machines -2147483648 - 2147483647 for 32 bit machines
Error checking / error reports: Error checking / error reports:
No error checking is performed.
The message `core dumped' signifies a syntax or semantic error.
Hosting Environment: No error checking is performed.
It might dump core if a syntax or semantic error is encountered.
Hosting Environment:
ANSI C, traditional K&R C or OSF ANDF ANSI C, traditional K&R C or OSF ANDF
ASCII or EBCIDIC character set ASCII or EBCIDIC character set
48K bytes memory 48K bytes memory
The Speed of DDS-BASIC Interpreter (Version 1.00). relative to The Speed of DDS-BASIC Interpreter (Version 1.00). relative to
Microsoft Advanced BASIC 3.31 is Approximately 60%. Microsoft Advanced BASIC 3.31 is Approximately 60%.
The code size could be further reduced by doing ugly things like The code size could be further reduced by doing ugly things like
not declaring the return type of functions, not freeing memory, not declaring the return type of functions, not freeing memory,
#defining define, and joining lines. In its present 1536 character #defining define, and joining lines. In its present 1536 character
form the program is reasonably portable (it may fail to run in a form the program is reasonably portable (it may fail to run in a
tagged object architecture) and nicely formatted (it fits in an tagged object architecture) and nicely formatted (it fits in an
80*25 screen). 80*25 screen).
Copyright (c) 1990, Landon Curt Noll & Larry Bassel. Copyright (c) 1990, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is All Rights Reserved. Permission for personal, educational or non-profit use is
+14 -11
View File
@@ -10,34 +10,37 @@
make all make all
NOTE: This entry might not compile when using modern compilers.
### To run ### To run:
echo foo bar | ./dg
### Try:
echo "to C or not to C" | ./dg echo "to C or not to C" | ./dg
## Judges' comments ## Judges' comments
Some C preprocessors got confused about single quotes in certain cases. Some C preprocessors got confused about single quotes in certain cases.
In particular, the following source line: In particular, the following source line:
b12(ase(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A)))))))))))))))))))))))))))))) b12(ase(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A))))))))))))))))))))))))))))))
sometimes has to be changed to: sometimes has to be changed to:
b12(ase(bco(acp(bi(acp(bcp(acp(bpl('A')))))))))))))))))))))))))))) b12(ase(bco(acp(bi(acp(bcp(acp(bpl('A'))))))))))))))))))))))))))))
if the C preprocessor botches single quotes in cpp expansions, which we have if the C preprocessor botches single quotes in cpp expansions, which we have
done for the wider audience. done for the wider audience.
## Author's comments ## Author's comments
If my preprocessor could hack it, I could write this as one single If my preprocessor could hack it, I could write this as one single
line rather than 4, but when I do that I get a complaint "defines line rather than 4, but when I do that I get a complaint "defines
nested too deeply". nested too deeply".
Spoiler: (rot13 to read) Spoiler: (rot13 to read)
Guvf vf nabgure ebg13 wbo (oryvrir vg be abg) - gur #qrsvarf ner n Guvf vf nabgure ebg13 wbo (oryvrir vg be abg) - gur #qrsvarf ner n
abiry jnl bs nqqvat gbxraf: '#qrsvar o12(k) 12 k' zrnaf gung ng abiry jnl bs nqqvat gbxraf: '#qrsvar o12(k) 12 k' zrnaf gung ng
+118 -116
View File
@@ -21,38 +21,44 @@
## To build: ## To build:
make all make all
### To run NOTE: as `btoa` is not common we used a ruby script from Yusuke Endoh. Thank you
Yusuke for your implementation of `btoa`!
echo "Quartz glyph jocks vend, fix, BMW." | ./compress | ./btoa | ./jaw ### Try:
## Judges' comments echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw
NOTE: part of this entry does not work under macOS.
The program, in its base form, implements two useful utilities: ## Judges' comments:
The program, in its base form, implements two useful utilities:
atob - ascii to binary conversion atob - ascii to binary conversion
zcat - decompression filter zcat - decompression filter
To test the official C entry, one might try: To test the official C entry, one might try:
echo "Quartz glyph jocks vend, fix, BMW." | compress | btoa | jaw echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw
which should apply the identity transformation to a minimal which should apply the identity transformation to a minimal
holoalphabetic sentence. holoalphabetic sentence.
Included with this entry is a shell script (with comments edited down Included with this entry is a shell script (with comments edited down
to reduce it to 1530 bytes) which implements the complete to reduce it to 1530 bytes) which implements the complete
shark utility. The script, shark.sh, contains a 'jaw.c' embedded shark utility. The script, shark.sh, contains a 'jaw.c' embedded
within it! within it!
The sender must have 'compress' and 'btoa'. To send, try: The sender must have 'compress' and 'btoa'. To send, try:
sh shark.sh jaw.* > receive sh shark.sh jaw.* > receive
The resulting file, 'receive', unpacks the input files The resulting file, 'receive', unpacks the input files
even if the receiver lacks 'uncompress' and 'atob': even if the receiver lacks 'uncompress' and 'btoa':
mkdir test mkdir test
cd test cd test
@@ -60,71 +66,68 @@
cmp ../jaw.c jaw.c cmp ../jaw.c jaw.c
cmp ../jaw.hint jaw.hint cmp ../jaw.hint jaw.hint
## Author's comments ## Authors' comments:
ABSTRACT ABSTRACT
Minimal, Universal File Bundling Minimal, Universal File Bundling
(or, Functional Obfuscation in a Self-Decoding Unix Shell Archive) (or, Functional Obfuscation in a Self-Decoding Unix Shell Archive)
James A. Woods James A. Woods
Universities Space Research Association Universities Space Research Association
NASA Ames Research Center NASA Ames Research Center
"Use an algorithm, go to jail." "Use an algorithm, go to jail."
[anon., circa 1988, pre-Morris worm era] [anon., circa 1988, pre-Morris worm era]
Myriad formats have been proposed for network-mailable Myriad formats have been proposed for network-mailable
data. A major difficulty undermining the popularity of most data. A major difficulty undermining the popularity of most
file/message bundlers is that the sender assumes prior file/message bundlers is that the sender assumes prior
installation of the computational dual of such bundling installation of the computational dual of such bundling
software by the receiver. Command shell archives alleviate software by the receiver. Command shell archives alleviate
this problem somewhat, but still require standardization for this problem somewhat, but still require standardization for
the function of data compression and mail-transparency the function of data compression and mail-transparency
encoding. On Unix, these coding format quandaries are over- encoding. On Unix, these coding format quandaries are over-
come by planting a novel Trojan Horse in the archive header come by planting a novel Trojan Horse in the archive header
to perform negotiationless decoding. to perform negotiation-less decoding.
Specifically, we outline the development of an extraor- Specifically, we outline the development of an extraordinarily compact
dinarily compact portable (un)bundler to (dis)assemble portable (un)bundler to (dis)assemble data-compressed,
data-compressed, binary-to-ASCII-converted, length-split, binary-to-ASCII-converted, length-split, and checksummed directory structures
and checksummed directory structures using standard Unix using standard Unix tools. Miniature versions of counterparts to a Lempel-Ziv
tools. Miniature versions of counterparts to a Lempel-Ziv coder ('compress' or 'squeeze') and an efficient bit packet- izer ('btoa') are
coder ('compress' or 'squeeze') and an efficient bit packet- compiled on-the-fly at mail destination sites where they may not already
izer ('btoa') are compiled on-the-fly at mail destination exist. These are written in purposefully obfuscated-C to accompany
sites where they may not already exist. These are written similarly-shrunk shell command glue. This resulting shell archiver is dubbed
in purposefully obfuscated-C to accompany similarly-shrunk 'shark'.
shell command glue. This resulting shell archiver is dubbed
'shark'.
'Shark' procedure overhead consumes as few as three 'Shark' procedure overhead consumes as few as three dozen shell lines (or
dozen shell lines (or ~1100 bytes), commensurate with the ~1100 bytes), commensurate with the size of many Internet mail headers; it
size of many Internet mail headers; it amortizes favorably amortizes favorably with message size. 'Shark' is portable across Unix
with message size. 'Shark' is portable across Unix vari- variants, while the underlying technique is inherently generalizable to other
ants, while the underlying technique is inherently general- encoding schemes.
izable to other encoding schemes.
In the function-theoretic sense of minimal In the function-theoretic sense of minimal
Chaitin/Kolmogorov complexity, and within a modified Shannon Chaitin/Kolmogorov complexity, and within a modified Shannon
model of communication, the 'shark' effort aims to construct model of communication, the 'shark' effort aims to construct
a "shortest program" for source decoding in the Turing- a "shortest program" for source decoding in the Turing-
universal Unix environment. universal Unix environment.
---------------------------------------------- ----------------------------------------------
Oh, the shark has pretty teeth, dear-- Oh, the shark has pretty teeth, dear--
And he shows them pearly white And he shows them pearly white
Just a jackknife has Macheath, dear-- Just a jackknife has Macheath, dear--
And he keeps it out of sight. And he keeps it out of sight.
[Bertolt Brecht, Threepenny Opera] [Bertolt Brecht, Threepenny Opera]
---------------------------------------------- ----------------------------------------------
We have ported this program to a wide variety of systems. Among We have ported this program to a wide variety of systems. Among
these are: these are:
SunOS 4.1 / Sun Sparcstation 1 (using both 'cc' and 'gcc 1.37.1') SunOS 4.1 / Sun Sparcstation 1 (using both 'cc' and 'gcc 1.37.1')
SunOS 4.0.3 / Sun 3 SunOS 4.0.3 / Sun 3
@@ -137,92 +140,91 @@
Dynix / Sequent Balance ('cc' for Natl. Semi. base + 'gcc 1.36') Dynix / Sequent Balance ('cc' for Natl. Semi. base + 'gcc 1.36')
Unicos / Cray 2 Unicos / Cray 2
We (the authors) feel this program is obfuscated for the We (the authors) feel this program is obfuscated for the
following reasons: following reasons:
(0) This is one of the few programs you'll see WHOSE VERY UTILITY
DEPENDS ON ITS OBFUSCATION!
(1) The contest entry may be used to send its wonderful self to 0. This is one of the few programs you'll see WHOSE VERY UTILITY DEPENDS ON ITS
anyone in the Unix world! Virus writers need not apply... OBFUSCATION!
(2) The basic idea is twisted enough to be patentable, but is, 1. The contest entry may be used to send its wonderful self to anyone in the
out of the kindness of our hearts (as well as to maintain Unix world! Virus writers need not apply...
eligibility for the large IOCCC prize fund), dedicated to
the public domain. Claude Shannon, meet Alan Turing.
(3) Meta-obfuscation is via obfuscated description (see ABSTRACT). 2. The basic idea is twisted enough to be patentable, but is, out of the
kindness of our hearts (as well as to maintain eligibility for the large IOCCC
prize fund), dedicated to the public domain. Claude Shannon, meet Alan Turing.
(4) "Literary" allusion. Production code contains a reference to 3. Meta-obfuscation is via obfuscated description (see ABSTRACT).
self-reference, preserved at amazing cost for sheer perversity.
(5) Many, many micro obfuscations below, honed over three years 4. "Literary" allusion. Production code contains a reference to self-reference,
time, in shell as well as C. Ask about the 'tar' pit escape, preserved at amazing cost for sheer perversity.
the argv[0] flip, Paul's &4294967295 portability hack, the
"void where prohibited by flaw" fix, the scanf() spacesaver,
shift shenanigans, signal madness, exit()ing stage left, and
source-to-source transformations galore.
For extra credit: 5. Many, many micro obfuscations below, honed over three years time, in shell as
well as C. Ask about the 'tar' pit escape, the argv[0] flip, Paul's &4294967295
portability hack, the "void where prohibited by flaw" fix, the scanf()
spacesaver, shift shenanigans, signal madness, exit()ing stage left, and
source-to-source transformations galore.
Construct 'sharkmail', to auto-split sharkives into mailable For extra credit:
segments and mail them. Here's a simple one, which could be
extended to enable auto-reassembly with one shell cmd at the
far end.
------------------------ cut here for sharkmail ----------------------- Construct 'sharkmail', to auto-split sharkives into mailable
#!/bin/sh segments and mail them. Here's a simple one, which could be
m=$1; shift extended to enable auto-reassembly with one shell cmd at the
shark $* | split -800 - /tmp/shark$$ far end.
n=`ls /tmp/shark$$* | wc -l | sed 's/ *//'`
p=0 ------------------------ cut here for sharkmail -----------------------
for f in `ls /tmp/shark$$*` #!/bin/sh
do m=$1; shift
p=`expr $p + 1` shark $* | split -800 - /tmp/shark$$
mail -s "bundle ($p of $n) from '`whoami`'" $m < $f n=`ls /tmp/shark$$* | wc -l | sed 's/ *//'`
done p=0
rm /tmp/shark$$* for f in `ls /tmp/shark$$*`
------------------------ end of sharkmail ----------------------------- do
p=`expr $p + 1`
mail -s "bundle ($p of $n) from '`whoami`'" $m < $f
done
rm /tmp/shark$$*
------------------------ end of sharkmail -----------------------------
Shark history: Shark history:
May 1987: Karl Fox introduces 1023-byte zcat.c to USENET. May 1987: Karl Fox introduces 1023-byte zcat.c to USENET.
It's too late for the 4th IOCCC. It's too late for the 4th IOCCC.
May 21, 1987: James A. Woods extends idea to construct self May 21, 1987: James A. Woods extends idea to construct self
decompressing shar Trojan horse, utilizing 'cc', 'shar', decompressing shar Trojan horse, utilizing 'cc', 'shar',
'zcat', & 'atob'; size: 2303 bytes. 'zcat', & 'btoa'; size: 2303 bytes.
May 23, 1987: 'jaw' trims 250 bytes without much thought. May 23, 1987: 'jaw' trims 250 bytes without much thought.
June 2, 1987: 52 lines of shell, 1991 bytes, now made with 'tar', June 2, 1987: 52 lines of shell, 1991 bytes, now made with 'tar',
short-circuit C-compile at far end, dual-use main.c, short-circuit C-compile at far end, dual-use main.c,
portability mods. (jaw) portability mods. (jaw)
Mar-May 1988: abortive run at 5th IOCCC. Mar-May 1988: abortive run at 5th IOCCC.
jaw.c - 1529 bytes. compile line: 152 bytes. jaw.c - 1529 bytes. compile line: 152 bytes.
generated funny code with execvp() to invoke shell. generated funny code with execvp() to invoke shell.
Aug 29, 1988: production version, now at 1830 bytes. Aug 29, 1988: production version, now at 1830 bytes.
Jan 1990: Paul Eggert does tour-de-force shark re-engineering. Jan 1990: Paul Eggert does tour-de-force shark re-engineering.
May 24, 1990: collaboration yields 999-byte jaw.c core (see above) May 24, 1990: collaboration yields 999-byte jaw.c core (see above)
and 1530-byte production shell code (w/comments). and 1530-byte production shell code (w/comments).
Eggert comes through with lion's share of improvements. Eggert comes through with lion's share of improvements.
7th IOCCC code now faster than the atob/zcat it replaces. 7th IOCCC code now faster than the btoa/zcat it replaces.
May 1990: 'jaw' develops experimental replacement using May 1990: 'jaw' develops experimental replacement using
Dan Bernstein's high-compression 'squeeze'. Dan Bernstein's high-compression 'squeeze'.
To which we add: To which we add:
June 1990: 'shark' wins the IOCCC, finally! :-) June 1990: 'shark' wins the IOCCC, finally! :-)
Copyright (c) 1990, Landon Curt Noll & Larry Bassel. Copyright (c) 1990, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel. from both Landon Curt Noll and Larry Bassel.
Executable
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env ruby
puts "xbtoa Begin"
data = $<.read
n, e, s, r = data.bytesize, 0, 0, 0
(-n % 4).times { data << 0 }
data.bytes do |b|
e, s, r = e ^ b, (s + b + 1) & 0xffffffff, (r * 2 + r[31] + b) & 0xffffffff
end
data.unpack("N*").flat_map do |v|
v == 0 ? [?z.ord] : (0..4).map {|i| v / 85**(4 - i) % 85 + 33 }
end.pack("C*").scan(/.{1,78}/) { puts $& }
puts "xbtoa End N %d %x E %x S %x R %x" % [n, n, e, s, r]
+2 -2
View File
@@ -1,5 +1,5 @@
for i in "${@?${usage?$0 file...}}";do<"$i"||exit;done for i in "${@?${usage?$0 file...}}";do<"$i"||exit;done
(cat&&tar cbf 1 - "$@"|compress|btoa&&echo w)<<\Z (cat&&tar cbf 1 - "$@"|compress|./btoa&&echo w)<<\Z
#!/bin/sh #!/bin/sh
# #
# GENTLE READER -- write this message to file [no headers!]; run "sh file". # GENTLE READER -- write this message to file [no headers!]; run "sh file".
@@ -13,7 +13,7 @@ PATH=$PATH:. a=atob m=unshark z=zcat
r="rm -f $a $m* $z" v="cc -o $z $m.c" r="rm -f $a $m* $z" v="cc -o $z $m.c"
trap "$r;exit 1" 1 2 13 15 trap "$r;exit 1" 1 2 13 15
echo decoding... echo decoding...
(:|compress|btoa|$a|$z)2>$m>&2||(sed '1,9s/./#define & / (:|compress|./btoa|$a|$z)2>$m>&2||(sed '1,9s/./#define & /
s/@/[w]/g s/@/[w]/g
s/C/char /g s/C/char /g
s/I/;if(/g s/I/;if(/g
+8 -8
View File
@@ -18,19 +18,19 @@
## Judges' comments ## Judges' comments
This program prints out a string. Can you figure out how This program prints out a string. Can you figure out how
it is done? it is done?
By use of pointers to functions returning a struct of pointers By use of pointers to functions returning a struct of pointers
to functions! to functions!
Note that some compilers will be unable to compile the Note that some compilers will be unable to compile the
expression 'X=g()...' in main due to lack of temporary expression 'X=g()...' in main due to lack of temporary
value space. One might want to try replacing main with: stack space. One might want to try replacing main with:
main(){X=s().v().o().o().l().S().d().l().i().o().w().N();} main(){X=s().v().o().o().l().S().d().l().i().o().w().N();}
if this is a problem. if this is a problem.
Spoiler: (rot13 to read) Spoiler: (rot13 to read)
+34 -33
View File
@@ -11,7 +11,7 @@
make all make all
Modern compilers might fail to compile this entry: Modern compilers might fail to compile this entry:
scjones.c:1:7: error: expected ';' after top level declarator scjones.c:1:7: error: expected ';' after top level declarator
char*a??(??)=??< char*a??(??)=??<
@@ -19,49 +19,50 @@
; ;
but we were able to get it to compile with modern compilers by specifying the but we were able to get it to compile with modern compilers by specifying the
`-ansi` flag with a tip from Yusuke Endoh. Thank you Yusuke! `-ansi` flag with a tip from Yusuke Endoh. Thank you Yusuke!
### To run ### To run:
./scjones ./scjones
## Judges' comments ## Judges' comments:
The addition of trigraphs has made it easier to make programs The addition of trigraphs has made it easier to make programs
hard to read. It was a dark and stormy night for C when the hard to read. It was a dark and stormy night for C when the
ANSI C committee added trigraphs to the standard. Too bad ANSI C committee added trigraphs to the standard. Too bad
that they didn't just simply require a more reasonable ISO that they didn't just simply require a more reasonable ISO
character set. character set.
## Author's comments ## Author's comments:
Since this year's contest is dedicated to ANSI C, here is a Since this year's contest is dedicated to ANSI C, here is a
strictly conforming entry. In accordance with the ANSI strictly conforming entry. In accordance with the ANSI
definition of a strictly conforming program it does not produce definition of a strictly conforming program it does not produce
output dependent on any unspecified, undefined, or implementation output dependent on any unspecified, undefined, or implementation
defined behavior, and it does not exceed any of the minimum defined behavior, and it does not exceed any of the minimum
implementation limits. It adheres to all of the syntactic and implementation limits. It adheres to all of the syntactic and
semantic constraints of the standard, #includes the relevant semantic constraints of the standard, #includes the relevant
headers for the functions it uses, and uses the EXIT_SUCCESS and headers for the functions it uses, and uses the EXIT_SUCCESS and
EXIT_FAILURE macros to return a correct success/fail status to EXIT_FAILURE macros to return a correct success/fail status to
the invoking program. It also uses trigraphs for characters the invoking program. It also uses trigraphs for characters
which are not in the Invariant Code Set of ISO 646:1983, so it which are not in the Invariant Code Set of ISO 646:1983, so it
will be portable to machines with deficient (from C's standpoint) will be portable to machines with deficient (from C's standpoint)
character sets. In short, it should be very widely portable. As character sets. In short, it should be very widely portable. As
an extra added attraction, all of the lines are under 72 an extra added attraction, all of the lines are under 72
characters long, which would allow for sequence numbers to be characters long, which would allow for sequence numbers to be
punched in columns 73-80 :-). punched in columns 73-80 :-).
[[ The Author sent us this note after he was informed that he won ]] [[ The Author sent us this note after he was informed that he won ]]
Although I am quite grateful for the "ANSI Committee's Worst Abuse > Although I am quite grateful for the "ANSI Committee's Worst Abuse of C" title
of C" title (were you aware that I am a member of the committee or (were you aware that I am a member of the committee or is the double meaning
is the double meaning unintentional?), I was really hoping for unintentional?), I was really hoping for something more along the lines of
something more along the lines of "Closest Resemblance to Line Noise." :-) "Closest Resemblance to Line Noise." :-)
[[ ... it was unintentional ]]
[[ ... it was unintentional ]]
Copyright (c) 1990, Landon Curt Noll & Larry Bassel. Copyright (c) 1990, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is All Rights Reserved. Permission for personal, educational or non-profit use is
+26 -22
View File
@@ -13,39 +13,43 @@
make all make all
NOTE: that's not a typo but one can also do:
./o
## Judges' comments ## Judges' comments
We changed the alias that the author's suggested alias from a We changed the alias that the author's suggested alias from a
C-shell alias to a zsh alias. C-shell alias to a zsh alias.
Note that shst.c is renamed to stig.c in the distribution. Note that shst.c is renamed to stig.c in the distribution.
WARNING: This program's 'how to compile' is too specific to a particular WARNING: This program's 'how to compile' is too specific to a particular
shell. The obfuscation of this program to more related to shell. The obfuscation of this program to more related to
shell obfuscation than C obfuscation. This type of entry will shell obfuscation than C obfuscation. This type of entry will
not be permitted in future contests. not be permitted in future contests.
## Author's comments ## Author's comments
If you like shell programming you may also admire my If you like shell programming you may also admire my
creative quoting. (I use echo to create an alias creative quoting. (I use echo to create an alias
which when run calls cc with the -D option to create a which when run calls cc with the -D option to create a
C macro with double quotes in it. ARRRRRGGGHHH!) C macro with double quotes in it. ARRRRRGGGHHH!)
The program is totally portable, but the compile The program is totally portable, but the compile
commands are very shell specific so don't be TOO mad commands are very shell specific so don't be TOO mad
at me if they don't work for you. at me if they don't work for you.
If you want to put these commands in a Makefile you If you want to put these commands in a Makefile you
must add 4 - four - backslashes at the end on first must add 4 - four - backslashes at the end on first
line. (At least that's what works here.) line. (At least that's what works here.)
If everything works correctly it create an executable If everything works correctly it create an executable
named c which checks whether your compiler supports named c which checks whether your compiler supports
nested comments. I've stolen the "/*/*/0*/**/1" from nested comments. I've stolen the `"/*/*/0*/**/1"` from
somewhere so don't give me any points for it. Of somewhere so don't give me any points for it. Of
course neither ANSI nor K&R support nested comments course neither ANSI nor K&R support nested comments
when properly implemented, but what the heck. when properly implemented, but what the heck.
Copyright (c) 1990, Landon Curt Noll & Larry Bassel. Copyright (c) 1990, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is All Rights Reserved. Permission for personal, educational or non-profit use is
+25 -14
View File
@@ -1,10 +1,17 @@
# Best Utility # Best Utility
Byron Rakitzis Sean Dorward Byron Rakitzis
Princeton University Princeton University Princeton University
5707 Old Lodge Dr. 10274 Burleigh Cottage Lane 5707 Old Lodge Dr.
Houston, TX 77066 Ellicott City, MD 21043 Houston, TX 77066
USA USA USA
Sean Dorward
Princeton University
10274 Burleigh Cottage Lane
Ellicott City, MD 21043
USA
## To build: ## To build:
@@ -16,13 +23,16 @@
## Judges' comments ## Judges' comments
This program implements a subject a well known Un*x utility whose
original source was considered to be extremely obfuscated by many
people, excluding its author. In fact, this utility was a major
inspiration for the formation of this contest.
The author supplied us with a slightly smaller unformatted version This program touches on a well known Unix utility, the 6th edition Bourne Shell
of the program which we include below: (`/bin/sh`), whose original source was considered to be extremely obfuscated by
many people (although Steve Bourne might disagree). Did you know that the Bourne
Shell source was a major inspiration for the formation of the IOCCC back in
1984?
The author supplied us with a slightly smaller unformatted version
of the program which we include below:
#define D ,close( #define D ,close(
char*c,q[512],m[256],*v[99],**u,*i[3];int f[2],p;main(){for(m[m[60]=m[62]= char*c,q[512],m[256],*v[99],**u,*i[3];int f[2],p;main(){for(m[m[60]=m[62]=
@@ -36,9 +46,10 @@
e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0):5;} e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0):5;}
Modern compilers had a problem with this entry because the exit(3) function Modern compilers had a problem with this entry because the exit(3) function
returns void but we were able to get it to compile by using the comma returns void but we were able to get it to compile by using the comma
operator which we also did in the smaller version. operator which we also did in the smaller version.
## Author's comments ## Author's comments
+67 -55
View File
@@ -11,91 +11,103 @@
make all make all
### To run NOTE: thanks to Yusuke Endoh for the pointing out that `atof()` nowadays needs
`#include <stdlib.h>` in order to get this to work. Thanks also to Cody Boone
Ferguson for fixing some segfaults under modern (and in some cases earlier)
systems with this entry.
## To run:
./theorem expression x1 x2 h y1
where:
expression - function f(x,y) (see below)
x1 - start of interval
x2 - end of interval
h - step size
y1 - initial value (y(x1) == y1)
## Try:
./theorem y 0 1 0.1 1 ./theorem y 0 1 0.1 1
## Judges' comments
The program's source implements four functions, all from the
same source file!
Usage: ## Judges' comments:
theorem expression x1 x2 h y1 The program's source implements four functions, all from the
same source file!
where: When you compile theorem.c as is and run with 5 args, it numerically
expression - function f(x,y) (see below) solves the equation y'=f(x,y), with a step size of h, over the interval
x1 - start of interval x=[x1,x2], with the initial condition of y(x1)=y1.
x2 - end of interval
h - step size
y1 - initial value (y(x1) == y1)
When you compile theorem.c as is and run with 5 args, it numerically The 'expression' f(x,y), is any function of 'x' and 'y' with the
solves the equation y'=f(x,y), with a step size of h, over the interval operators:
x=[x1,x2], with the initial condition of y(x1)=y1.
The 'expression' f(x,y), is any function of 'x' and 'y' with the + - * / ^
operators:
+ - * / ^
The symbol '^' is the power operator. Note that it only supports The symbol '^' is the power operator. Note that it only supports
integer powers. Also note that all expressions are evaluated strictly integer powers. Also note that all expressions are evaluated strictly
left to right. (i.e., parenthesis aren't supported). left to right. (i.e., parenthesis aren't supported).
Try running the program with the following args: Try running the program with the following args:
./theorem y 0 1 0.1 1 ./theorem y 0 1 0.1 1
./theorem 1/x 1 2 0.1 0 ./theorem 1/x 1 2 0.1 0
./theorem 'x^2/y+x' 0 1 0.1 6 ./theorem 'x^2/y+x' 0 1 0.1 6
But wait, there is more! You also get, free of charge, a But wait, there is more! You also get, free of charge, a
reversing filter! Try: reversing filter! Try:
./theorem -r 0 0 0 0 < theorem.c > sorter.c ./theorem -r 0 0 0 0 < theorem.c > sorter.c
Still not impressed? The author throws in for free, a Still not impressed? The author throws in for free, a
sort program! Try: sort program! Try:
cc sorter.c -o sorter cc sorter.c -o sorter
ls | ./sorter ls | ./sorter
This program is safe for home use as well. The author has
included a safety feature in case you misplace the original
program source:
./sorter -r 0 0 0 0 < sorter.c > theorem_bkp.c This program is safe for home use as well. The author has
included a safety feature in case you misplace the original
And finally, as a special offer to users of this entry, program source:
the author provides a Fibonacci sequence generator! Try:
./sorter 0 0 0 0 < theorem.c > fibonacci.c ./sorter -r 0 0 0 0 < sorter.c > theorem_bkp.c
cc fibonacci.c -o fibonacci
./fibonacci 1 1
./fibonacci 2 1
Program available 9 track and cartridge cassette. Gensu knife And finally, as a special offer to users of this entry,
not included! :-) the author provides a Fibonacci sequence generator! Try:
When this program was first shown at the 1990 Summer Usenix ./sorter 0 0 0 0 < theorem.c > fibonacci.c
conference, it received a standing ovation; a first for cc fibonacci.c -o fibonacci
a contest entry. ./fibonacci 1 1
./fibonacci 2 1
It should be noted that the 4 trailing args '0 0 0 0', are Program available 9 track and cartridge cassette. Gensu knife
required on systems that dump core when NULL is dereferenced. not included! :-)
When this program was first shown at the 1990 Summer Usenix
conference, it received a standing ovation; a first for
a contest entry.
Originally we noted that the 4 trailing args '0 0 0 0' were required on systems
that dump core when NULL is dereferenced but this problem showed itself in
modern systems even with the 4 '0 0 0 0'. To make this easier for users Cody
Boone Ferguson kindly fixed this problem.
## Author's comments ## Author's comments
Differential equations are solved via the Runge-Kutta method, Differential equations are solved via the Runge-Kutta method,
which guarantees local error proportional to h^5, and total which guarantees local error proportional to h^5, and total
error across a finite interval is at most a constant times h^4. error across a finite interval is at most a constant times h^4.
Sorting is accomplished with a standard shell sort.
Note that the sorting and reversing is limited to files with Sorting is accomplished with a standard shell sort.
fewer than 500 lines, each less than 99 characters long.
Note that the sorting and reversing is limited to files with
fewer than 500 lines, each less than 99 characters long.
Copyright (c) 1990, Landon Curt Noll & Larry Bassel. Copyright (c) 1990, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is All Rights Reserved. Permission for personal, educational or non-profit use is
+7 -3
View File
@@ -1,12 +1,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h> #include <math.h>
#define X #define X
#define Y {} #define Y {}
#define C } #define C }
#define o { #define o {
#undef main #undef main
char m[500][99],v[99],R; char m[500][99],v[99],R,*a;
int*a,b,n,i,j,W,A; int b,n,i,j,W,A;
float Q,G,D,M,T,B,O,U,V,N,y,e(); float Q,G,D,M,T,B,O,U,V,N,y,e();
P(g,R,u)float*g,R,u;{int c;for(*g=1,c=u;c--;*g*=R);} P(g,R,u)float*g,R,u;{int c;for(*g=1,c=u;c--;*g*=R);}
X X
@@ -77,7 +79,7 @@ for(j=0;j<n;puts(j++[m]));
e("",O,O,a); e("",O,O,a);
n=j-(O=1); n=j-(O=1);
while(gets(j++[m])); while(gets(j++[m]));
if(!strcmp(*++a,"-r"))S(); if(!strcmp(++a,"-r"))S();
C C
/**/main(A,a)int A;char*a[]; /**/main(A,a)int A;char*a[];
Y Y
@@ -90,4 +92,6 @@ float Q,G,D,M,T,O,B,U,V,N,e();
#define o } #define o }
#define C { #define C {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h> #include <math.h>
+5 -1
View File
@@ -10,12 +10,16 @@
make all make all
NOTE: This entry might not compile when using modern compilers. NOTE: This entry might not compile when using modern compilers.
### To run ### To run
./westley 1 ./westley 1
NOTE: this entry will segfault without an arg and will enter an infinite loop if
input is not a number (or is a negative number).
## Judges' comments ## Judges' comments
usage: westley <number> usage: westley <number>
+4 -1
View File
@@ -912,7 +912,7 @@ Contest </I></FONT></CENTER>
<LI>A minor bug that shows up in some cases was found by <LI>A minor bug that shows up in some cases was found by
<a href="winners.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a> <a href="winners.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a>
when working on his <a href="#2020_ferguson2">2020 Enigma machine</a>. See his when working on his <a href="#2020_ferguson2">2020 Enigma machine</a>. See his
README.md file for details (search for vik). README.md file for details (search for vik).</LI>
</UL> </UL>
<A NAME="2014_wiedijk"></A> <A NAME="2014_wiedijk"></A>
<P><B>wiedijk</B> - Y combinator</P> <P><B>wiedijk</B> - Y combinator</P>
@@ -2938,6 +2938,9 @@ README.md file for details (search for vik).
<UL TYPE=square> <UL TYPE=square>
<LI><A HREF="1990/theorem/Makefile">Makefile</A> <LI><A HREF="1990/theorem/Makefile">Makefile</A>
<LI><A HREF="1990/theorem/theorem.c">theorem.c</A> <LI><A HREF="1990/theorem/theorem.c">theorem.c</A>
<LI><a href="winners.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a> fixed
some segfaults under modern systems (and in some cases older systems) in this
entry. Thank you Cody!</LI>
</UL> </UL>
<A NAME="1990_westley"></A> <A NAME="1990_westley"></A>
<P><B>westley</B> - poetic exchange between lovers, prints &quot;luvs me, luvs not&quot;</P> <P><B>westley</B> - poetic exchange between lovers, prints &quot;luvs me, luvs not&quot;</P>