Merge pull request #686 from xexyl/2012-endoh1

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-05-04 19:21:07 +09:30
commit e0a699eba7
419 files changed
+18998 -9350

No files matched your search

+1
View File
@@ -3,6 +3,7 @@
*.dSYM
.*.sv[a-z]
.*.sw[a-z]
.su[a-z]
.DS_Store
.sv[a-z]
.sw[a-z]
+12 -7
View File
@@ -1,14 +1,19 @@
In 1984, the first contest was held. The name of the contest was simply
``Obfuscated C Code Contest''.
# First Obfuscated C Code Contest
Look at the README.md file for the given winner for information on how to
compile the winner and how to run the winning program. Look at the winning
source and try to figure how it does what it does! You may then wish to look at
the Author's remarks for even more details.
In [1984](/years.html#1984), the first contest was held. The name of the contest was simply
"`Obfuscated C Code Contest`".
Look at the `README.md`file for the given winner for information on how to
compile the entry and how to run the winning program. Look at the winning
source and try to figure how it does what it does! This year we only had
remarks from two authors but which came years later.
Restrictions against machine dependent code were not in the [rules](rules.txt)
in 1984. The source file size restriction was only 512 bytes. Rules and results
were posted to net.lang.c and net.unix-wizards.
were posted to [net.lang.c](https://groups.google.com/g/net.lang.c) and
[net.unix-wizards](https://groups.google.com/g/net.unix-wizards). The contest
was announced in a [net.lang.c
post](https://groups.google.com/g/net.lang.c/c/lx-TAuEyeRI/m/HdOOnNx6LC0J).
=-=
+13 -10
View File
@@ -1,22 +1,25 @@
# Dishonorable mention
Anonymous
Anonymous
## To build:
make all
```sh
make all
```
## To run:
./anonymous
```sh
./anonymous
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work
under macOS. The fix was to prototype `read()` prior to being defined and not
using `int, int, int` as the entry does. Instead the second arg is a `void *`.
In the `read()` function which actually calls `write(2)` the `i` (which is the
`void *` has to be cast to an `int`. This solves the problem. Thank you Cody for
In the `read()` function (which actually calls `write(2)`) the `i` (which is the
`void *`) has to be cast to an `int`. This solves the problem. Thank you Cody for
your assistance!
@@ -47,7 +50,7 @@ Some years after this entry was published we asked the author if they still
wished to remain anonymous and they said:
> Yes, I want to keep my anonymity. But you can tell them that I am well known
for my connection to the C language.'
for my connection to the C language.
### On the famous tattoo (see above):
@@ -63,10 +66,10 @@ Landon Curt Noll, the one who told the author about the tattoo, wrote back:
### Regrets:
Landon Curt Noll wrote that the author, if they had to do it over again, regrets not
making the program a one-liner and not moving the "int i" into an arg of main
making the program a one-liner and not moving the `int i` into an arg of main
(so that the line would have started with main). On the other hand the author
likes the "two line look" and the way hell o was split. :-) And they like the
fact that it ends in a smily face: ;}
likes the "two line look" and the way `hell o` was split. :-) And they like the
fact that it ends in a smily face: `;}`
## Copyright and CC BY-SA 4.0 License:
+3
View File
@@ -137,6 +137,9 @@ ${PROG}: ${PROG}.c
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} -traditional-cpp $< -o $@ ${LIBS}
# data files
#
data: ${DATA}
+20 -16
View File
@@ -1,19 +1,23 @@
# Second place award
Dave Decot
Dave Decot
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to not
require `-traditional-cpp` which not all compilers support (clang does not
support it for example). Clang is also more strict about the args' types in
`main()` and this was also a problem that Cody fixed, making it work with both
clang and gcc. For the original code with the gcc fix described below, see the
alternate code section below. Thank you Cody for your assistance!
Originally [Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch so that
this entry would compile with gcc - but not clang - or at least some versions.
Thank you Yusuke! [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson)
noticed this did not work under fedora linux and it definitely didn't work with
macOS as it required a compiler that supports `-traditional-cpp` which clang
does not. Clang also requires that the second and third arguments to main be a
`char **`. Cody fixed both problems and now it works under both macOS and linux
- clang and gcc. Thank you Cody for your assistance!
Thank you Yusuke!
## To run:
@@ -21,13 +25,13 @@ does not. Clang also requires that the second and third arguments to main be a
./decot
```
### Alternative code:
### Alternate code:
The alternative code, [decot.alt.c](decot.alt.c), is the fix that Cody made to
the version that does require `-traditional-cpp` and still runs afoul with
clang's requirement for the second and third arguments to main() being a `char
**` (the fixed version's main() only has one arg, an int). It is a minor fix to
Yusuke's fix. Thank you Yusuke and Cody!
The alternate code, [decot.alt.c](decot.alt.c), is the original code that
requires `-traditional-cpp` and will also run afoul with clang's requirement for
the second and third arguments to main() being a `char **` (the fixed version's
main() only has one arg, an int). It is a minor fix to Yusuke's fix. Thank you
Yusuke and Cody!
To try this version:
@@ -43,7 +47,7 @@ This program prints out a string of garbage.
The judges also offer this one comment: understand remarks!
### Historical comments:
### Historical remarks:
Some new (in 1984) compilers disliked line 15 of the original source, so we changed it
from:
@@ -65,7 +69,7 @@ To see what we mean look at the source file in the
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+21 -11
View File
@@ -1,14 +1,18 @@
# Third place
Mike Laman
Mike Laman
## To build:
make all
```sh
make all
```
## To run:
./laman <positive number>
```sh
./laman <positive number>
```
### INABIAF - it's not a bug it's a feature :-)
@@ -22,9 +26,11 @@ arg.
The program accepts ONE POSITIVE argument. Seeing is believing, so try things
like:
./laman 4
./laman 9
./laman 16
```sh
./laman 4
./laman 9
./laman 16
```
This code should run you in circles.
@@ -33,19 +39,23 @@ This code should run you in circles.
Some new compilers dislike lines 6 and 10 of the source, so we changed
them from:
;++f)a[ b<<5|c] =d++,b+ =e;for( f=0;f<O
<<5|c]^ =a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
```c
;++f)a[ b<<5|c] =d++,b+ =e;for( f=0;f<O
<<5|c]^ =a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
```
to:
;++f)a[ b<<5|c] =d++,b+= e;for( f=0;f<O
<<5|c]^= a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
```c
;++f)a[ b<<5|c] =d++,b+= e;for( f=0;f<O
<<5|c]^= a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
```
I hope you have a C beautifier!
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+33 -21
View File
@@ -1,58 +1,70 @@
# The Grand Prize
Sjoerd Mullender
Sjoerd Mullender
Robbert van Renesse
Robbert van Renesse
## To build:
make all
```sh
make all
```
## To run:
./mullender
```sh
./mullender
```
> NOTE: If your machine is not a Vax-11 or pdp-11, this program will
> not execute correctly. In later years, machine dependent
> code was discouraged.
## Alternative code:
### Alternative code:
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) added the alternative
code which lets you run this on other systems. He notes though that this was
only a slight fix and enhancement to the change in the [faq](/faq.md). Thank you
Cody for your assistance!
### To build:
#### To build:
make alt
```sh
make alt
```
### To run:
#### To run:
./mullender.alt [microseconds]
```sh
./mullender.alt [microseconds]
```
The default microseconds is 10000. This ability is so you can experiment with
The default microseconds is 10000. This feature is so you can experiment with
different speeds in between writes. It can be useful if your CPU is too slow or
too fast.
BTW: is there such a thing as too fast a CPU ? :-) actually yes for certain code
which is probably not as uncommon as you think :-) ).
BTW: is there such a thing as too fast a CPU ? :-) Actually yes for certain code
which is probably not as uncommon as you think :-).
Note that it is an int and it uses `atoi()` which does NOT check for
overflow! In fact it's argc itself.
## Try:
#### Try:
./mullender.alt
```sh
./mullender.alt
./mullender.alt 5000
./mullender.alt 5000
./mullender.alt 500
./mullender.alt 500
./mullender.alt 20000
./mullender.alt 20000
./mullender.alt 100000
```
What happens if you hit enter after it writes a line of output?
@@ -84,7 +96,7 @@ BTW: this remains my (Landon Curt Noll's) all time favorite entries!
## Author's remarks:
These comments, found at
These remarks, found at
[https://lainsystems.com/posts/exploring-mullender-dot-c/](https://lainsystems.com/posts/exploring-mullender-dot-c/),
were provided by Sjoerd Mullender years later. We thank the author of the
article for the quote!
@@ -123,11 +135,11 @@ would fit, some as an ASCII character.
The rest is history.
Since this was the first contest, we hadn't seen any old entries, nor had any of
the other contestants. Of course we knew about #define and tricks you could do
the other contestants. Of course we knew about `#define` and tricks you could do
with that, but we didn't need that for this program. In fact, we made it as
“standard” as possible. At the time there was this program called “cb” for C
“standard” as possible. At the time there was this program called `cb` for C
beautifier which would re-indent your program to make the layout look better. Our
program is idempotent under cb.
program is idempotent under `cb`.
## Copyright and CC BY-SA 4.0 License:
+9 -6
View File
@@ -1,16 +1,19 @@
1985 marked the second year of the International Obfuscated C Code Contest.
# [1985](/years.html#1985) marked the second year of the International Obfuscated C Code Contest.
Look at the README.md file for the given winner for information
on how to compile the winner and how to run the winning program.
Look at the `README.md` file for the given winner for information
on how to compile the entry and how to run the winning program.
Look at the winning source and try to figure how it does what it does!
You may then wish to look at the Author's remarks for even more details.
Hints against machine dependent code were added to the [rules](rules.txt) to
avoid another 1984 style winner ([1984/mullender](../1984/mullender)). Rules and
results were posted to net.lang.c and net.unix-wizards. Larry Bassel was
invited to help in the judging. Awards were given to 5 classes of programs
avoid another 1984 style winner ([1984/mullender](../1984/mullender)).
[Rules](rules.txt) and [results](/years.html#1985) were posted to
[net.lang.c](https://groups.google.com/g/net.lang.c) and
[net.unix-wizards](https://groups.google.com/g/net.unix-wizards). Larry Bassel
was invited to help in the judging. Awards were given to 5 classes of programs
since we were unable to select only the best 4.
=-=
Copyright (c) 1985, Landon Curt Noll & Larry Bassel.
+1 -1
View File
@@ -61,7 +61,7 @@ CDEFINE=
# Include files that are needed to compile
#
CINCLUDE=
CINCLUDE= -include unistd.h
# Optimization
#
+17 -8
View File
@@ -1,20 +1,29 @@
# Best one liner
Jack Applin [with help from Robert Heckendorn]
Jack Applin [with help from Robert Heckendorn]
<https://web.archive.org/web/19991006042323/http://www.geocities.com/HotSprings/6789/>
## To build:
make all
```sh
make all
```
## Try:
./applin
```sh
./applin
```
NOTE: [Yusuke Endoh](/winners.html#Yusuke_Endoh) provided a patch to get this to
not issue a bus error. Thank you Yusuke! [Cody Boone
Ferguson](/winners.html#Cody_Boone_Ferguson) noted that this entry does not work
under macOS. Try it out and see for yourself what happens!
not issue crash and [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson)
fixed this to work with macOS. The problem with the crash is that it
destructively rewrites string literals but with `strdup()` it's safe. For macOS
it's because there was no prototype for `execlp()` and macOS has problems with
missing prototypes for some functions (this was also seen when Cody fixed
[1984/anonymous](/1984/anonymous/anonymous.c) for macOS as well though that fix
was more complicated). Ironically this fix was discovered through linux! Thank
you Yusuke and Cody for your help!
## Judges' remarks:
@@ -24,7 +33,7 @@ certainly takes its time saying hello.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+15 -9
View File
@@ -1,26 +1,32 @@
# The most obscure program
Lennart Augustsson
<chalmers!augustss>
Lennart Augustsson
<https://web.archive.org/web/20090831055828/http://www.cs.chalmers.se/~augustss>
## To build:
make all
```sh
make all
```
## To run:
./august
```sh
./august
```
## Try:
./august | head -n 10
```sh
./august | head -n 10
```
If you have the `primes(6)` tool (sometimes part of BSD Games) you can see
what of the output in the first N (say 15) lines are primes:
while read -r n ; do primes "$n" $((n + 1)) ; done < <((./august | head -n 15 ))
```sh
while read -r n ; do primes "$n" $((n + 1)) ; done < <((./august | head -n 15 ))
```
## Judges' remarks:
@@ -34,7 +40,7 @@ memory or until they sell your computer, which ever comes first.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+1 -1
View File
@@ -58,7 +58,7 @@ ARCH=
# Defines that are needed to compile
#
CDEFINE=
CDEFINE= -DZ=0
# Include files that are needed to compile
#
+16 -3
View File
@@ -1,6 +1,6 @@
# The strangest appearing program
Ed Lycklama
Ed Lycklama
## To build:
@@ -13,7 +13,20 @@ make all
modern compilers. In the past 'define' in `#define` could even be defined but to
get this to work on modern systems Cody changed the `#o` lines to `#define`. The
`lycklama.alt.c` is the original source code as it provides some fun input for
the entry.
the entry. Thank you Cody! With a tip from [Yusuke
Endoh](/winners.html#Yusuke_Endoh) it was indirectly noticed that if one slows
down the call to `write()` one can see some fun output that's not visible with
modern systems so Cody added a call to `usleep()`. The default time is `0`
which disables it (in order to make it as close to original as possible; an alt
version already exists mostly for fun output). In order to change the speed (try
500 or 700) do:
```sh
make CDEFINE+="-DZ=700" clobber all
```
Thank you Yusuke!
## Try:
@@ -55,7 +68,7 @@ The program itself looks like tty noise.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+1 -1
View File
@@ -9,7 +9,7 @@
#define o_ main
#define o__ if
#define oo_ 0
#define _o(_,__,___)(void)___o(_,__,ooo(___))
#define _o(_,__,___)(void)___o(_,__,ooo(___),Z&&usleep(Z))
#define __o (o_o_<<((o_o_<<(o_o_<<o_o_))+(o_o_<<o_o_)))+(o_o_<<(o_o_<<(o_o_<<o_o_)))
o_(){_o_ _=oo_,__,___,____[__o];_oo ______;_____:___=__o-o_o_; _______:
_o(o_o_,____,__=(_-o_o_<___?_-o_o_:___));o_o(;__;_o(o_o_,"\b",o_o_),__--);
+8 -6
View File
@@ -1,15 +1,18 @@
# Grand prize for most well-rounded in confusion
Carl Shapiro
Carl Shapiro
## To build:
make all
```sh
make all
```
## Try:
./shapiro
```sh
./shapiro
```
## Judges' remarks:
@@ -18,7 +21,6 @@ As submitted, this program was 3 lines (2 of defines and 1 of code).
To make news & mail happy we split the last line into 7. The file
[shapiro.alt.c](shapiro.alt.c) is the original version.
This program was selected for the 1987 t-shirt collection.
We found this program is be simply a**maze**ing! Run this program without
@@ -26,7 +28,7 @@ arguments and notice the output.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+8 -8
View File
@@ -1,6 +1,6 @@
# The worst abuse of the C preprocessor
Col. G. L. Sicherman
Col. G. L. Sicherman
## To build:
@@ -9,8 +9,8 @@ make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this very twisted
entry to not require `-traditional-cpp`. He'd like to refer you to the original
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this _very twisted
entry_ to not require `-traditional-cpp`. He'd like to refer you to the original
file in [sicherman.alt.c](sicherman.alt.c) and he suggests that you then compare
it to [sicherman.c](sicherman.c) for some good old C-fashioned fun! Thank you
Cody for your assistance!
@@ -36,10 +36,10 @@ Use `sicherman.alt` as you would `sicherman`.
## Judges' remarks:
This program abuses the C preprocessor so much that some /lib/cpp fail to
strip out all of the comments on the first pass! If you were able to
understand Decot's entry in 1984, you will have a head start on this
one.
This program abuses the C preprocessor so much that some /lib/cpp fail to strip
out all of the comments on the first pass! If you were able to understand
[Decot's](/winners.html#Dave_Decot) [entry in 1984](/1984/decot/decot.c), you
will have a head start on this one.
Be sure to run this program through lint! If your lint works
correctly, it should warn you that the argument 'Manual' isn't used.
@@ -57,7 +57,7 @@ results in diff reporting a difference on some machines.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+18 -10
View File
@@ -1,23 +1,31 @@
The 1986 contest was named: "The Third International Obfuscated C Code Contest"
# The 1986 contest was named "The Third International Obfuscated C Code Contest"
Look at the README.md file for the given winner for information
on how to compile the winner and how to run the winning program.
Look at the `README.md` file for the given winner for information
on how to compile the entry and how to run the winning program.
Look at the winning source and try to figure how it does what it does!
You may then wish to look at the Author's remarks for even more details.
The [rules for 1986](rules.txt) suggested categories due to the success of the 1985
The [rules for 1986](rules.txt) suggested categories due to the success of the
[1985](/years.html#1985)
judging method. The maximum size was increased from 512 to 1024 bytes.
Larry Bassel joined as the second official judge.
A poll was taken for the worst code for BSD and System V program.
The Bourne Shell (/bin/sh) won for both systems. The BSD finger
A poll was taken for the worst code for
[BSD](https://en.wikipedia.org/wiki/Berkeley_Software_Distribution) and [System
V](https://en.wikipedia.org/wiki/UNIX_System_V) program. The [Bourne
Shell](https://en.wikipedia.org/wiki/Bourne_shell) (`/bin/sh`) won for both
systems. The BSD [finger](https://en.wikipedia.org/wiki/Finger_(protocol))
program took third place.
[Rules](rules.txt) and results were posted to net.lang.c and net.unix-wizards.
Micro/Systems Journal started regular publishing of the winners.
The practice of making first announcement of the winners at the Summer
Usenix BOF started this year. A notice was posted to net.announce.
[Rules](rules.txt) and [results](/years.html#1986) were posted to
[net.lang.c](https://groups.google.com/g/net.lang.c) and
[net.unix-wizards](https://groups.google.com/g/net.unix-wizards).
[Micro/Systems
Journal](https://www.vintage-computer.com/publications.php?microsystemsjournal)
started regular publishing of the winners. The practice of making first
announcement of the winners at the Summer Usenix BOF (Birds of a Feather)
started this year. A notice was posted to net.announce.
=-=
+14 -10
View File
@@ -1,24 +1,28 @@
# Most adaptable program
Jack Applin
Hewlett-Packard
Ft. Collins
Colorado
USA
Jack Applin
US
<https://web.archive.org/web/19991006042323/http://www.geocities.com/HotSprings/6789/>
## To build:
make all
```sh
make all
```
## To run:
./applin
```sh
./applin
```
## Try:
sh applin.c
```sh
sh applin.c
./applin
./applin
```
## Judges' remarks:
@@ -30,7 +34,7 @@ compilers as well as executable by the Bourne shell!
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+9 -10
View File
@@ -1,20 +1,19 @@
# Best complex task done in a complex way
Lennart Augustsson
Dept. of Comp. Sci.
Chalmers University of Technology,
412 96 Gothenburg
Sweden
Lennart Augustsson
<https://web.archive.org/web/20090831055828/http://www.cs.chalmers.se/~augustss>
## To build:
make all
```sh
make all
```
## Try:
./august
```sh
./august
```
NOTE: this entry is very likely to core dump after its output.
@@ -31,7 +30,7 @@ enough to try and parse it correctly.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+12 -7
View File
@@ -1,21 +1,26 @@
# Most useful obfuscation
Walter Bright
Walter Bright
## To build:
make all
```sh
make all
```
## To run:
./bright some_file
```sh
./bright some_file
```
## Try:
./bright bright.c
./bright bright
```sh
./bright bright.c
./bright bright
```
## Judges' remarks:
@@ -28,7 +33,7 @@ maintain the Bourne shell! :-}
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+14 -10
View File
@@ -1,13 +1,13 @@
# Worst abuse of the C preprocessor
Jim Hague
University of Kent at Canterbury
Canterbury, Kent
Jim Hague
UK
## To build:
make all
```sh
make all
```
NOTE: this entry uses gets() so you might get a warning about this when
@@ -15,15 +15,19 @@ compiling and running this program with some systems.
## To run:
```sh
./hague
# enter some text
```
## Try:
./hague
IOCCC
International Obfuscated C Code Contest
Jim Hague
```sh
./hague
IOCCC
International Obfuscated C Code Contest
Jim Hague
```
## Judges' remarks:
@@ -35,13 +39,13 @@ others.
This program was selected for the 1987 t-shirt collection.
Think Morse code when you ponder this program. Note how use of
similar variables can be obfuscating! The author notes that this
similar variables can be obfuscating! The author noted that this
program implements the international Morse standard. Now for extra
credit, what Morse message does the program spell out?
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+8 -7
View File
@@ -1,14 +1,13 @@
# Best simple task performed in a complex way
Bruce Holloway
Digital Research, Inc.
Monterey, CA
USA
US
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to
compile and work with clang (it already worked with gcc). The problem was that
@@ -20,7 +19,9 @@ Cody for your assistance!
## Try:
./holloway
```sh
./holloway
```
## Judges' remarks:
@@ -32,7 +33,7 @@ this version as the first C program!
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+8 -8
View File
@@ -1,14 +1,12 @@
# Best layout
Eric Marshall
System Development Corporation, a Burroughs Company
P.O. Box 517
Paoli, PA.
19301
Eric Marshall
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) got this to
@@ -20,7 +18,9 @@ Cody for your help!
## Try:
./marshall
```sh
./marshall
```
# Judges' remarks:
@@ -34,7 +34,7 @@ This program was selected for the 1987 t-shirt collection.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+7 -6
View File
@@ -7,14 +7,15 @@ San Diego, Ca
## To build:
make all
```sh
make all
```
## Try:
./pawka
```sh
./pawka
```
## Judges' remarks:
@@ -24,7 +25,7 @@ is obfuscated, of all things!
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+8 -7
View File
@@ -1,11 +1,12 @@
# Best one liner
Jan Stein
Jan Stein
## To build:
make all
```sh
make all
```
## Judges' remarks:
@@ -16,9 +17,9 @@ the original file.
Try the program with the following argument:
./stein ^N^N
```sh
./stein ^N^N
```
(^N is ASCII control-N). One some machines, ^M^L is needed to get it to
output cleanly. Your system may require another set of characters.
@@ -26,7 +27,7 @@ In time, you will figure out what it does. :-)
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+4 -7
View File
@@ -1,10 +1,7 @@
# The grand prize in most well-rounded in confusion
Larry Wall
System Development Corporation
Santa Monica
California
US of A
US
## To build:
@@ -17,7 +14,7 @@ this work with gcc (in particular the patch uses `strdup()` on two strings).
Thank you Yusuke! [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed
this so that it does not require `-traditional-cpp`. This took a fair bit of
tinkering as this entry *is* strange. The original code is provided to allow one
to easily see how different C was in these days. See below for details. Thank
to easily see how different C was in those days. See below for details. Thank
you Cody for your assistance!
## To use:
@@ -49,14 +46,14 @@ This caused a number of System V C pre-preprocessors to gripe about a
syntax error.
This program is a masterpiece of obfuscation and humor. Larry Wall
(the hacker who gave us rn and patch) asks you to compile and consider
(the hacker who gave us `rn` and `patch`) asks you to compile and consider
the warning message generated by the C compiler. Then execute the
program and type characters into its standard input. You will see why
the compiler documents the program.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+13 -8
View File
@@ -1,6 +1,6 @@
# Best Abuse of the Rules
Mark Biggar
Mark Biggar
UNiSYS - System Development Group, Santa Monica
2525 Colorado AV MD 91-01
Santa Monica, CA
@@ -8,27 +8,32 @@ Santa Monica, CA
## To build:
make all
```sh
make all
```
## To run:
some_command | ./biggar | od -c
```sh
some_command | ./biggar | od -c
```
## Try:
cat biggar.c | ./biggar | od -c
```sh
cat biggar.c | ./biggar | od -c
```
## Judges' remarks:
By changing the compile line you can make this program do anything you
want. This is a very efficient way to transfer source, though it
want. This is a very efficient way to transfer source, though it
increases the size of Makefiles.
With only slight variations, this program can be set to many uses.
Consider how easy it would be to release `Un*x` source in this form;
so what if the make files grow a little! :-)
so what if the Makefiles grow a little! :-)
One vendor's lint got hung in an infinite loop over this entry!
@@ -47,7 +52,7 @@ an infinite loop by this entry.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+19 -14
View File
@@ -5,8 +5,9 @@ Pixar
## To build:
make all
```sh
make all
```
On System V systems, we had to compile with `-Dindex=strchr`.
To compile on a 16 bit machine, change 300000 to 30000.
@@ -15,35 +16,39 @@ To compile on a 16 bit machine, change 300000 to 30000.
## Try:
./heckbert 40 < heckbert.c > ph.c; make ph
./ph 21 < heckbert.c > bar.c; make bar
# or more generally fold some other file at a positive column:
./ph col < file
```sh
./heckbert 40 < heckbert.c > ph.c; make ph
./ph 21 < heckbert.c > bar.c; make bar
# or more generally fold some other file at a positive column:
./ph col < file
```
Ask yourself what happens to `foo.md` if you try:
./ph 40 < README.md > foo.md
```sh
./ph 40 < README.md > foo.md
```
## Judges' remarks:
Folding at the wrong length may be equivalent to a "Spindle or Mutilate" operation. For example:
./heckbert 40 < heckbert.c > ph.c ; make ph ; ./ph 20 < heckbert.c > bar.c ; make bar
```sh
./heckbert 40 < heckbert.c > ph.c ; make ph ; ./ph 20 < heckbert.c > bar.c ; make bar
```
Try not to
[Fold, Spindle or Mutilate](https://repository.library.brown.edu/studio/item/bdr:788264/PDF/)
files. :-)
## Author's remarks:
No comments were provided by the author.
The judges used this program to fold up very long lines which the
BSD fold(1) was unable to process. This program has been added
to the contest tool chest.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+18 -10
View File
@@ -5,30 +5,38 @@ OnLine Computer Systems
4200 Farragut Street
Hyattsville, MD
20781
USA
US
## To build:
make all
```sh
make all
```
## To run
## To run:
./hines file.c
```sh
./hines file.c
```
## Try:
./hines hines.c
```sh
./hines hines.c
```
### Alternate code
### Alternate code:
An alternate version of this entry is in `hines.alt.c`. With older compilers you
An alternate version of this entry is in [hines.alt.c](hines.alt.c). With older compilers you
can try the alt version:
make alt
```sh
make alt
```
Use `hines.alt` as you would `hines` above.
## Judges' remarks
## Judges' remarks:
This program was designed to maximize the bother function for
structured programmers. This program takes goto statements to their
@@ -41,7 +49,7 @@ See the Communications of the ACM, March 1987, Page 195-196.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+33 -21
View File
@@ -1,15 +1,17 @@
# Best One Liner
David Korn
David Korn
AT&T Bell Labs
MH 3C-526B, AT&T Bell Labs
Murray Hill, NJ
07974
USA
MH 3C-526B, AT&T Bell Labs
Murray Hill, NJ
07974
US
## To build:
make all
```sh
make all
```
## Judges' remarks:
@@ -21,34 +23,44 @@ section right now and see if you are one of the few people who can.
Several points are important to understand in this program:
1) What is the symbol 'unix' and what is its value in the program?
Clearly 'unix' is not a function, and since 'unix' is not declared
to be a data type (such as int, char, struct foo, enum, ...)
what must 'unix' be?
1. What is the symbol `unix` and what is its value in the program? Clearly
`unix` is not a function, and since `unix` is not declared to be a data type
(such as `int`, `char`, `struct foo`, `enum`, ...) what must `unix` be?
2) What is the value of the symbol "have"? (hint: the value is
NOT 4 characters, or 'h', or a string) Consider the fact that:
2. What is the value of the symbol `"have"`? (hint: the value is NOT 4
characters, or `'h'`, or a string) Consider the fact that:
char *x;
defines a pointer to a character (i.e. an address), and that
the '=' assigns things is compatible types. Since:
char *x;
defines a pointer to a character (i.e. an address), and that the `=` assigns
things of compatible types. Since:
x = "have";
is legal C, what type of value is "have"?
is legal C, what type of value is `"have"`?
3) Note that the following expressions yield the same value:
3. Note that the following expressions yield the same value:
x[3] *(x+3) *(3+x)
since addition is communitive. What can be said about the value:
x[3] *(x+3) *(3+x)
3[x]
since addition is commutative. What can be said about the value:
David Korn's /bin/ksh provides us with a greatly improved version of
3[x]
?
David Korn's `/bin/ksh` provides us with a greatly improved version of
the /bin/sh. The source for v7's /bin/sh greatly inspired this contest.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+21 -16
View File
@@ -2,21 +2,24 @@
Roemer B. Lievaart
VU Informatica
Churchilllaan 173-IV
Amsterdam, The Netherlands
Churchilllaan 173-IV
Amsterdam, The Netherlands
## To build:
make all
```sh
make all
```
NOTE: The original entry may be built with "make alt" if you have an old enough
compiler.
## To run:
./lievaart
# enter a level and start playing as described below
```sh
./lievaart
# enter a level and start playing as described below
```
NOTE: if you enter invalid input the program will enter an infinite loop
displaying a string like `"You:"` repeatedly.
@@ -25,8 +28,10 @@ displaying a string like `"You:"` repeatedly.
To see what it would have looked like without the size restrictions:
./lievaart2
# enter a level and start playing as described below
```sh
./lievaart2
# enter a level and start playing as described below
```
## Judges' remarks:
@@ -34,19 +39,19 @@ To see what it would have looked like without the size restrictions:
We believe that you too will be amazed at just how much power Mr. Lievaart
packed into 1024 bytes!
This Plays the game of reversi (Othello)! Compile and run. It then
This Plays the game of Reversi (Othello)! Compile and run. It then
asks for a playing level. Enter 0-10 (easy-hard). It then asks for
your move. A move is a number within 11-88, or a 99 to pass. Illegal
moves (except for an illegal pass) are rejected. Then the computer
does its move (or a 0 to pass), until the board is full.
It plays rather well, for such a small program! Lievaart had to leave out the
board printing routine, so you'll have to take a real game board to
play it. ... Also due to space-limitations (the rules for 1987 had a
limit of 1024 byes), Lievaart took out the passing-handler, which
makes its ending-game rather poor. But further it knows all the
rules, uses alpha-beta pruning, and it plays f.i. on mobility(!).
Most important: it can play a pretty good game of Reversi!
board printing routine, so you'll have to take a real game board to play it (or
see below). ... Also due to space-limitations (the rules for 1987 had a limit
of 1024 byes), Lievaart took out the passing-handler, which makes its
ending-game rather poor. But further it knows all the rules, uses alpha-beta
pruning, and it plays f.i. on mobility(!). Most important: it can play a pretty
good game of Reversi!
The Author was kind enough to supply the fully functional version of the
program. The file lievaart2.c contains what the program would have
@@ -56,7 +61,7 @@ logic and displays the board after each move!
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+25 -18
View File
@@ -1,9 +1,7 @@
# Most Useful Obfuscation
Larry Wall
Unisys - System Development Group Santa Monica
9132 Kester Ave
Panorama City, CA 91402 USA
US
## To build:
@@ -23,35 +21,44 @@ make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this safer by
using `fgets()` instead of `gets()`. This prevents a potentially alarming
warning at linking or runtime.
using `fgets()` instead of `gets()`. This prevents an annoying and potentially
alarming warning at compiling, linking or runtime.
## Try:
./wall | bc | ./wall
```sh
./wall | bc | ./wall
```
and input the following:
x*x
c^2
m*m
```
x*x
c^2
m*m
# can you figure out what this does?
500
# can you figure out what this does?
500
```
### Also try:
./wall | bc
```sh
./wall | bc
./wall | cat
./wall | cat
```
and enter some input like:
x*x
2^x
quit # for the cat version
```
x*x
2^x
quit # for the cat version
```
## Judges' remarks:
@@ -64,12 +71,12 @@ be directly called. Even so, these pointers to functions are being
used as an argument to signal. Can you determine why this is being
done and how it is being exploited?
Some compilers complained about this file, so we changed: '=++I' to '= ++I'.
Some compilers complained about this file, so we changed: `=++I` to `= ++I`.
## Author's remarks:
No comments were provided by the author.
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+26 -16
View File
@@ -1,34 +1,40 @@
# Best Layout
Brian Westley (aka Merlyn Leroy on usenet)
Starfire Consulting
1121 Hamline Ave. N. #17
St. Paul, MN
55108
USA
http://www.westley.org
Brian Westley (aka Merlyn Leroy on usenet)
Starfire Consulting
1121 Hamline Ave. N. #17
St. Paul, MN
55108
US
<http://www.westley.org>
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for modern
systems. The problem was 'assignment to cast is illegal, lvalue casts are not
supported'. For the original file see below. Thank you Cody for your assistance!
## Alternate code:
## To run:
```sh
./westley
```
### Alternate code:
If you have an older compiler you can try compiling the original source code
which is true symmetry:
make alt
```sh
make alt
```
## To run:
./westley
Use `westley.alt` as you would `westley` above.
## Judges' remarks:
@@ -40,7 +46,11 @@ top of the program.
Line by line symmetry performed better than any C beautifier. Think
of if it as a C ink blot. :-)
NOTE: This entry requires a non-standard K&R C compiler to compile.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+27 -16
View File
@@ -1,20 +1,24 @@
# Best of show
Jack Applin
Hewlett-Packard
3404 E. Harmony Rd
Ft. Collins, CO
80525
USA
Jack Applin
Hewlett-Packard
3404 E. Harmony Rd
Ft. Collins, CO
80525
US
<https://web.archive.org/web/19991006042323/http://www.geocities.com/HotSprings/6789/>
## To build:
make all
```sh
make all
```
## Try:
./applin
```sh
./applin
```
## Judges' remarks:
@@ -22,19 +26,26 @@ This entry is by far the most unusual abuse of the C preprocessor that
we have received thus far. Nearly all of the real work is done in the
preprocessor!
When we compiled applin.c on an Amdahl 5890-300E, we found that it
spent over 75 minutes in the System V C preprocessor! Besides showing
that the standard System V cpp is slow, it showed that it contained a
memory usage problem. The applin.c only uses 29 different preprocessor
symbols (besides `stdio.h`) and yet the preprocessor ran out of space!
When we compiled [applin.c](applin.c) on an
[Amdahl](https://en.wikipedia.org/wiki/Amdahl_Corporation) 5890-300E, we found that it
spent over 75 minutes in the System V C preprocessor! Besides showing that the
standard System V cpp is slow, it showed that it contained a memory usage
problem. The [applin.c](applin.c) only uses 29 different preprocessor symbols
(besides `stdio.h`) and yet the preprocessor ran out of space!
The GNU C preprocessor took less than 45 seconds to perform the 2nd pass
on the Amdahl 5890-300E. But due to the ANSI-likeness of GNU cpp (v. 1-21),
it was not able to cleanly substitute a symbol that began with a '#'.
Clearly the GNU C preprocessor is faster.
A smaller version of applin.c can be found in zsmall.c. Your machine
may have an easier time with this program. See the Makefile for details.
A smaller version of [applin.c](applin.c) can be found in [zsmall.c](zsmall.c).
Your machine may have an easier time with this program. See the Makefile for
details.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
+15 -9
View File
@@ -1,11 +1,11 @@
## Best abuse of system calls
Paul Dale
University of Queensland
Computer Science Dept
Dept of Computer Science
Uni of Qld, 4067
Australia
Paul Dale
University of Queensland
Computer Science Dept
Dept of Computer Science
Uni of Qld, 4067
Australia
## To build:
@@ -56,9 +56,10 @@ Thank you Cody for your assistance!
## Try:
./dale hello world
./dale these files are in this directory: *
```sh
./dale hello world
./dale these files are in this directory: *
```
NOTE: in linux it might happen that core dumps are created when running this
entry even though it works fine.
@@ -71,6 +72,11 @@ system calls.
NOTE: This program assumes the ASCII character set is being used.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+23 -10
View File
@@ -1,19 +1,23 @@
# Best visuals
Mark Isaak
Imagen Corporation
2650 San Tomas Expy.
Santa Clara, CA
95052-8101
USA
Mark Isaak
Imagen Corporation
2650 San Tomas Expy.
Santa Clara, CA
95052-8101
US
## To build:
make all
```sh
make all
```
## To run:
./isaak
```sh
./isaak
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work for
modern systems. The problem was that the important function, a redefinition of
@@ -25,7 +29,9 @@ alternative version. Thank you Cody for your assistance!
The original version of this code is in [isaak.alt.c](isaak.alt.c).
The original entry starts with the line:
```c
main(){};
```
This works on some systems. Why? Note that `#include <stdio.h>` is given on
the last line. Why is this needed? Note the unusual calls to sprintf.
@@ -50,14 +56,21 @@ due to the fact that BSD style systems have an sprintf() that returns a `char *`
Due to the above problems, we placed the output of this program in the file:
isaak.encode. To read this file do:
uudecode < isaak.encode
cat isaak.output
```sh
uudecode < isaak.encode
cat isaak.output
```
But since Cody fixed it this is not strictly necessary. See the
[isaak.alt.c](isaak.alt.c) for the original source.
FYI: We are likely to be more strict about portability in the future.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+24 -14
View File
@@ -1,15 +1,17 @@
## Best small program
Maarten Litmaath
Free University (VU) Amsterdam
Department of computer science
Uilenstede 72
1183 AK Amstelveen
The Netherlands
Maarten Litmaath
Free University (VU) Amsterdam
Department of computer science
Uilenstede 72
1183 AK Amstelveen
The Netherlands
## Try:
./litmaath eschew obfuscation
```sh
./litmaath eschew obfuscation
```
## Judges' remarks:
@@ -17,9 +19,10 @@
Note the unusual structure:
while (<condition>)
;
```c
while (<condition>)
;
```
Did you notice that the body is empty?
@@ -30,15 +33,22 @@ could make the body of the 'while' loop an 'fprintf' with interesting
variables like:
fprintf(stderr,
"argv=%lo *argv=%lo **argv=%c argv[1]=%lo *argv[1]=%c argc=%d\n",
(long) argv, (long) *argv, *argv && **argv ? **argv : '@',
(long) argv[1], argv[1] && *argv[1] ? *argv[1] : '@', argc);
```c
fprintf(stderr,
"argv=%lo *argv=%lo **argv=%c argv[1]=%lo *argv[1]=%c argc=%d\n",
(long) argv, (long) *argv, *argv && **argv ? **argv : '@',
(long) argv[1], argv[1] && *argv[1] ? *argv[1] : '@', argc);
```
Furthermore, it's interesting to note that only two variables are
used to achieve everything.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+15 -9
View File
@@ -1,17 +1,18 @@
## Least likely to compile successfully
Ian Phillipps
Cambridge Consultants Ltd
Science Park
Milton Road
Cambridge CB4 4DW
England
Ian Phillipps
Cambridge Consultants Ltd
Science Park
Milton Road
Cambridge CB4 4DW
England
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for modern
@@ -23,7 +24,7 @@ be `char **` :-) ) with the correct args it now works. Thank you Cody for your
assistance!
## Judges' remarks
## Judges' remarks:
Compile and run without parameters.
@@ -33,6 +34,11 @@ and thus represents a new departure in text compression standards.
The judges thought that this program looked like what you would get
by pounding on the keys of an old typewriter at random.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+18 -9
View File
@@ -1,29 +1,38 @@
## Most useful Obfuscated C program
Amperif Corporation
9232 Eton Avenue
Chatsworth, CA
91311
U.S.A.
Amperif Corporation
9232 Eton Avenue
Chatsworth, CA
91311
U.S.A.
## To build:
make all
```sh
make all
```
## Try:
./reddy
char *(*(fun[16])();
```sh
./reddy
char *(*(fun[16])();
```
## Judges' remarks
## Judges' remarks:
This is a somewhat restricted version of a useful program that has been
posted to Usenet. What is unusual is what it is able to do so much
in such little space.
## Author's remarks:
No remarks were provided by the author.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+33 -21
View File
@@ -1,45 +1,57 @@
## Best abuse of C constructs
Arch D. Robison
University of Illinois at Urbana-Champaign
1304 W. Springfield Ave.
Urbana IL
61801
USA
Arch D. Robison
University of Illinois at Urbana-Champaign
1304 W. Springfield Ave.
Urbana IL
61801
US
## To build:
make all
```sh
make all
```
## Try:
./robison 80 10
./robison 40 16
```sh
./robison 80 10
./robison 40 16
```
The first and second parameters are optional. You might also try:
./robison 80 2 <--- can you find the bug?
./robison 80 -246
```sh
./robison 80 2 # <--- can you find the bug?
./robison 80 -246
```
The author says:
> This program shows that C has many unnecessary constructs, in fact
> only "while","--", and ">=" are required. (The two assignments at
> the beginning could be avoided if "atoi" was rewritten with this
> new paradigm.) Note that the lack of both the controversial "goto"
> and assignment statements makes the meaning crystal clear. The current
> ANSI committee should look into this practical simplification of C.
## Judges' remarks:
The following might make an interesting benchmark:
./robison 100
```sh
./robison 100
```
[Amdahl 5890-300E with System V cc: 8.40 seconds]
We suggest that you C pre-process and perhaps C-beautify this program.
All is not what it may appear to be in this program. Why does a whi1e
All is not what it may appear to be in this program. Why does a `whi1e`
not take a while to execute?
## Author's remarks:
This program shows that C has many unnecessary constructs, in fact
only "while","--", and ">=" are required. (The two assignments at
the beginning could be avoided if "atoi" was rewritten with this
new paradigm.) Note that the lack of both the controversial "goto"
and assignment statements makes the meaning crystal clear. The current
ANSI committee should look into this practical simplification of C.
## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+31 -26
View File
@@ -8,8 +8,9 @@ Greece
## To build:
make all
```sh
make all
```
and then type a C program into followed by EOF (usually `^D`, ctrl-d).
@@ -19,23 +20,25 @@ Thank you Cody for your assistance!
## Try:
make clobber all
main()
{
printf("Hello world\n");
}
^D
./spinellis
```sh
make clobber all
main()
{
printf("Hello world\n");
}
^D
./spinellis
make clobber all
int main()
{
int i;
for (i = 0; i < 5; ++i)
printf("%d\n", i);
}
^D
./spinellis
make clobber all
int main()
{
int i;
for (i = 0; i < 5; ++i)
printf("%d\n", i);
}
^D
./spinellis
```
NOTE: you need to make clobber first for this entry to work right.
@@ -43,15 +46,17 @@ NOTE: you need to make clobber first for this entry to work right.
For clang try the alt code like:
make clobber alt
#include <stdio.h>
main()
{
puts("Hello world\n");
}
^D
./spinellis
```sh
make clobber alt
#include <stdio.h>
main()
{
puts("Hello world\n");
}
^D
./spinellis
```
NOTE: you need to make clobber first for this entry to work right.
+1
View File
@@ -1 +1,2 @@
westley
westley.alt
+2 -2
View File
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
+49 -18
View File
@@ -1,40 +1,71 @@
## Best layout
Merlyn LeRoy (Brian Westley)
Rosemount, Inc.
1121 Hamline Ave. N. #17
St. Paul, MN
55108
U.S.A.
Merlyn LeRoy (Brian Westley)
Rosemount, Inc.
1121 Hamline Ave. N. #17
St. Paul, MN
55108
U.S.A.
<http://www.westley.org>
http://www.westley.org
## To build:
```sh
make all
```
Misha Dynin provided a fix for [westley.c](westley.c) so that it may compile on
both K&R and more modern C compilers. Thank you Misha! The original code, used
for entertainment and educational value, is in [westley.alt.c](westley.alt.c),
described below.
## Try:
make all
./westley
```sh
./westley
```
## Judges' remarks
## Judges' remarks:
Your compiler must parse
#define _ -a
-_
```c
#define _ -a
-_
```
as "--a" and not "-(-a)" or some other tokenized form. Some strictly
as `--a` and not `-(-a)` or some other tokenized form. Some strictly
conforming ANSI C Preprocessors may object to this: for such
compilers, you can elide the non-standard token-pasting requirement
by changing the #define line to:
#define _ F-->00||F-OO--;
```c
#define _ F-->00||F-OO--;
```
You might enjoy looking at the output of:
cc -E westley.c
```sh
cc -E westley.c
```
### Alternate code:
To see if your compiler has the problem described above try:
```sh
make alt
./westley.alt
```
Does it show the same output as `westley`?
## Author's remarks:
No remarks were provided by the author.
Misha Dynin provided a fix for westley.c so that it may compile on
both K&R and more modern C compilers.
## Copyright and CC BY-SA 4.0 License:
+20
View File
@@ -0,0 +1,20 @@
#define _ -F<00||--F-OO--;
int F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}
+22 -15
View File
@@ -1,40 +1,47 @@
# Best self-modifying program
Jay Vosburgh
Sequent Computer Systems, Inc
15450 SW Koll Parkway
Beaverton, OR
97006
USA
Jay Vosburgh
Sequent Computer Systems, Inc
15450 SW Koll Parkway
Beaverton, OR
97006
US
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) got this to work with
modern systems. Thank you Cody for your assistance!
## To run
## To run:
./fubar number>
```sh
./fubar <number>
```
## Try:
./fubar 2
```sh
./fubar 2
```
## Judges' remarks
## Judges' remarks:
Run this with a single digit argument (or wait a long time).
The blank line at the beginning of the source is mandatory.
Do you know why?
NOTE: don't try running `ouroboros.c` directly with an arg as it'll turn into an
infinite loop. The same will happen with larger numbers.
NOTE: don't try running [ouroboros.c](ouroboros.c) (note that it's executable)
directly with an arg as it'll turn into an infinite loop. The same will happen
with larger numbers.
## Author's remarks
## Author's remarks:
In a nutshell, this is probably the slowest and most
obnoxious factorial program ever written. Unfortunately,
@@ -46,7 +53,7 @@ The shell script compiles itself, and then executes the
resulting binary, giving the source as input. The program
works by successively modifying #define lines each pass through.
Both "indent" and "cb" will damage the program, "indent"
Both `indent` and `cb` will damage the program, `indent`
much more so.
## Copyright and CC BY-SA 4.0 License:
+18 -12
View File
@@ -1,34 +1,40 @@
# Strangest abuse of the rules
Jari Arkko
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
Jari Arkko
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
## To build and run:
make clobber all
```sh
make clobber all
```
## Judges notes:
## Judges' remarks:
On many systems the compiler will not allow you to send the object file to
/dev/tty. The author suggested:
cc -c -o /dev/tty jar.1.c
```sh
cc -c -o /dev/tty jar.1.c
```
On systems that have symbolic links, we suggest:
ln -s /dev/tty jar.1.o
cc -c jar.1.c
```sh
ln -s /dev/tty jar.1.o
cc -c jar.1.c
```
As a last resort the scripts provided simply cat the .o file to the terminal.
Abuse of the rules winners usually result in a change of the rules. Starting in
1990, compiling entries must result an regular file which can be executed.
## Selected notes from the author:
## Author's remarks:
This program is (supposedly) the smallest C program able to print "Hello
world.". The compilation itself produces the desired printout and the program
+40 -18
View File
@@ -1,33 +1,41 @@
## Best of show
Jari Arkko, Ora Lassila, Esko Nuutila
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
Jari Arkko, Ora Lassila, Esko Nuutila
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work with
modern compilers. Modern compilers do not allow code like:
#define D define
#define a include
```c
#define D define
#define a include
#D foo bar
#a <stdio.h>
#D foo bar
#a <stdio.h>
```
He notes that there _is_ a way to get it (or something close to it) to work. Do
you know how?
Thank you Cody for your assistance!
## To run:
./jar.2
[enter some lisp]
```sh
./jar.2
[enter some lisp]
```
NOTE: this entry will likely segfault on invalid input.
@@ -40,15 +48,27 @@ all this functionality in such a small, densely packed program,
is impressive enough to win the Best of show award.
## Selected notes from the author:
## Author's remarks:
This program implements a Lisp interpreter in 1465 bytes of source.
Some sophisticated features supported, eg. functionals and recursion.
The special-forms/functions/variables implemented are:
+ - * < ()
car cdr cons defun equal
function if lambda quote t
- \+
- \-
- \*
- \<
- ()
- car
- cdr
- cons
- defun
- equal
- function
- if
- lambda
- quote
- t
Below are sample lisp expressions you might choose to try as input.
The program implements a conventional lisp listener, i.e. you type in
@@ -56,6 +76,7 @@ lisp expressions (followed by CR), the program evaluates them and
prints out the return values. End execution by typing an end-of-file
character.
```lisp
(+ 2.5 3.1)
(defun fib (n)
(if (< n 2)
@@ -74,6 +95,7 @@ character.
(cons (quote (f)) ())
(car (quote (a b c)))
(cdr (cdr (quote (g h i))))
```
Please do not leave any whitespace before the first parenthesis when
+1
View File
@@ -1 +1,2 @@
ovdluhe
ovdluhe.alt
+5 -2
View File
@@ -115,8 +115,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
@@ -138,6 +138,9 @@ ${PROG}: ${PROG}.c
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# data files
#
data: ${DATA}
+29 -12
View File
@@ -1,14 +1,16 @@
## Most humorous output
Oskar von der Luehe
Institut fuer Astronomie
ETH - Zentrum
8092 Zuerich
Switzerland
Oskar von der Luehe
Institut fuer Astronomie
ETH - Zentrum
8092 Zuerich
Switzerland
## To build:
make all
```sh
make all
```
To get this to compile with a modern CPP, we had to replace `#D` with `#define`.
@@ -16,19 +18,34 @@ To get this to compile with a modern CPP, we had to replace `#D` with `#define`.
Run the program this way:
./ovdluhe < textfile
```sh
./ovdluhe < textfile
```
The program stops when it reaches the end of the template buffer
by chance or is killed.
## Try:
./ovdluhe < ./ovdluhe.c
./ovdluhe < ./ovdluhe.c
```sh
./ovdluhe < ./ovdluhe.c
./ovdluhe < ./ovdluhe.c
./ovdluhe < README.md
./ovdluhe < README.md
./ovdluhe < README.md
./ovdluhe < README.md
```
### Alternate code:
The author suggested that one varies the definition of `P` from 2 through 10. As
it's a `#define` it's easy to set up which [Cody Boone
Ferguson](/winners.html#Cody_Boone_Ferguson) did for us. To use try:
```sh
make CFLAGS="-DP=9" clobber alt
```
Use `ovdluhe.alt` as you would `ovdluhe`.
## Judges' remarks:
@@ -38,7 +55,7 @@ recommended. You will get different output each time you run it.
## Selected notes from the author:
## Author's remarks:
This program implements an "Eddington ape" - it generates
random text from a supplied template. The template text file
+26
View File
@@ -0,0 +1,26 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
typedef char ape;
#define EA register
#define EP unsigned
#define A 1
#define AP (A<<A)
#ifndef P
#define P (A<<AP)
#endif
#define AE ((P<<P)<<A)
#define PE (((A<<P)<<P)<<P)
#define E ((EP)A>>A)
#define APE {EA EP ape,ea=AE;while(ea--) e[ea]=E;}
PA();
;ape a[PE+A],ap,*ae,p[P+A],e[AE];
main(){ape pe,*ep=a;srand((EP)time((long)E));
while(((*(ep++)=getchar())!=-A)&&((ep-a)<PE));
*(ae= --ep)=E;for(ap=E;ap<=P;){APE;if(pe=PA())
{putchar(pe);if(ap<P){p[ap]=pe;ap++;}else{
ep=p+A;while(*ep) *(ep-A)= *(ep++); *(ep-A)=pe;}}else break;}}
PA(){EA ape pe,*ep=a,pa,Ap=E;for(ep=a;ep<ae-P;ep++)
if(!strncmp(ep,p,ap)){e[*(ep+ap)]++;Ap++;}if(!Ap)return(Ap);
pa=rand()%Ap+A;pe=~E,Ap=!Ap;while((Ap+=e[++pe])<pa);return(pe);}
+16 -12
View File
@@ -1,20 +1,24 @@
## Most complex algorithm
Paul E. Black
CIRRUS LOGIC, Inc.
1463 Centre Pointe Dr.
Milpitas, CA
95035
USA
Paul E. Black
CIRRUS LOGIC, Inc.
1463 Centre Pointe Dr.
Milpitas, CA
95035
US
## To build:
make all
```sh
make all
```
## Try:
./paul
```sh
./paul
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault under
macOS. The problem was that the int (from `#define f`) should be a long. This
@@ -31,9 +35,9 @@ removing the trailing "\" on line 12 and joining lines 12 and
WHAT FOLLOWS IS A DETAILED PROGRAM EXPLANATION AND SPOILER.
IF YOU WANT A REAL CHALLENGE, DON'T READ ANY FURTHER AND TRY
TO UNDERSTAND THE PROGRAM VIA THE SOURCE.
Selected notes from the author:
## Author's remarks:
This programs computes and prints Fibonacci numbers by
simulating a Turing machine with the proper program.
@@ -78,8 +82,8 @@ If bit 4 (16&byte) is true, the next character is sent to
stdout. (I added this feature so programs could print
results.)
The Turing machine has next state 'j' when it begins. The
cycle is 1) exit if the state is 'x', 2) find the next
The Turing machine has next state `j` when it begins. The
cycle is 1) exit if the state is `x`, 2) find the next
instruction (given the state and the character under the scan
head). [The program string is searched forward for the next
matching instruction. If the end of the string is reached, the
+30 -21
View File
@@ -1,15 +1,17 @@
## Best minimal use of C
Arch D. Robison
University of Illinois
1304 W. Springfield Ave.
Urbana, IL
61801
USA
Arch D. Robison
University of Illinois
1304 W. Springfield Ave.
Urbana, IL
61801
US
## To build:
make all
```sh
make all
```
NOTE: we were able to get this to compile under modern systems with a patch from
@@ -18,24 +20,27 @@ Yusuke!
## To run:
./robison
# enter valid expressions
```sh
./robison
# enter valid expressions
```
## Try:
./robison
11x10
```sh
./robison
11x10
echo 1x10x111 | ./robison
echo 1x10x111 | ./robison
echo 1+1+10 | ./robison
echo 1+1+10 | ./robison
echo 100 - 1 | ./robison
echo 100 - 1 | ./robison
echo -100 x 100 + 1 | ./robison
echo -100 x 100 + 1 | ./robison
echo 100 / 100 | ./robison # <-- what happens here ?
echo 100 / 100 | ./robison # <-- what happens here ?
```
NOTE: this entry will crash with numbers with non binary digits.
@@ -50,7 +55,7 @@ constructs that the C language supports.
NOTE: this entry will likely dump core with invalid input.
## Selected notes from the author:
## Author's remarks:
This program is a handy picoAPL interpreter written in C--. It
outputs the evaluation of an APL expression from standard
@@ -58,13 +63,17 @@ input. Functions are limited to dyadic +,-,x, and unary -;
numerals must be binary. Parentheses may be used for
grouping. For example:
101x111-100
```
101x111-100
```
prints:
1111
```
1111
```
That is 5x(7-4) is 15. (APL groups from right to left.)
That is `5x(7-4)` is `15`. (APL groups from right to left.)
Extending it to the full APL language should be trivial.
The C-- language improves the C language by removing superfluous
+14 -11
View File
@@ -1,34 +1,37 @@
## Best layout
Lievaart, Roemer B.
VU-Informatica, Amsterdam
Marcusstraat 29/2,
NL 1091 TJ Amsterdam
Netherlands
Lievaart, Roemer B.
VU-Informatica, Amsterdam
Marcusstraat 29/2,
NL 1091 TJ Amsterdam
Netherlands
## To build:
make all
```sh
make all
```
## Try:
./roemer
```sh
./roemer
```
## Judges' remarks:
Do you know what this program does? If you do, look again,
there is more here than meets the PI.
## Selected notes from the author:
## Author's remarks:
Passes lint, but not with the strictest options, for it
contains some "null-statements", as well two identifiers
which are, if compilers only take 6 characters, the same. It
also uses write(2), so not totally system independent.
You are very much invited to pass this program through a
C-beautifier. (First strip newlines and tabs, if your cb can't
do that.)
You are very much invited to pass this program through a C-beautifier. (First
strip newlines and tabs, if your `cb` can't do that.)
## Copyright and CC BY-SA 4.0 License:
+58 -46
View File
@@ -1,15 +1,16 @@
# Best game
John Tromp
Centre for Mathematics and Computer Science (CWI)
Oetgensstraat 7
1701CK Heerhugowaard
Netherlands
John Tromp
Centre for Mathematics and Computer Science (CWI)
Oetgensstraat 7
1701CK Heerhugowaard
Netherlands
## To build:
make all
```sh
make all
```
We used a patch from [Yusuke Endoh](/winners.html#Yusuke_Endoh)
to get this to compile under gcc. Thank you Yusuke for your assistance!
@@ -24,6 +25,40 @@ being created) and after this making sure the terminal stayed sane (the letter
high score file was reinstated). We thank you for your assistance Cody (he
cynically notes that he did it because tetris just has to work)!
## To run:
```sh
./tromp [drops_per_sec [cmd_string]]
```
## Try:
```sh
./tromp 5
# fast with vim keys
# h - left (left)
# k - rotate (arbitrary, in vim k = up)
# l - right (right)
# j - drop (down)
# space - pause (literal space in vim)
# q - quit (similar to :q in vim)
./tromp 10 "hklj q"
```
NOTE: after this game ends a file called `HI` will be in the directory with the
high scores (up to 20 runs saved) so one can see who has the highest score. The
file might look like:
```
330 by cody
136 by cody
```
.... hey, I haven't played in a very long time and the lower one was hitting
space (default drop) in rapid succession :-)
### Alternate code:
@@ -32,39 +67,14 @@ were unable to see the improvements in modern systems even after fixing it to
compile (the high score file was not created at all) but if you have an old
compiler you can try compiling it in its original unmodified form by running:
make alt
```sh
make alt
```
Use `tromp.alt` as you would `tromp` above.
## To run:
./tromp [drops_per_sec [cmd_string]]
## Try:
./tromp 5
# fast with vim keys
# h - left (left)
# k - rotate (arbitrary, in vim k = up)
# l - right (right)
# j - drop (down)
# space - pause (literal space in vim)
# q - quit (similar to :q in vim)
./tromp 10 "hklj q"
NOTE: after this game ends a file called `HI` will be in the directory with the
high scores (up to 20 runs saved) so one can see who has the highest score. The
file might look like:
330 by cody
136 by cody
.... hey, I haven't played in a very long time and the lower one was hitting
space (default drop) in rapid succession :-)
## Judges' remarks
## Judges' remarks:
This is a character terminal version of the TETRIS program.
It runs on a VT100 compatible terminal or emulator. It is
@@ -75,23 +85,23 @@ will drop in a second, is 2. The default "cmd_string" is
"jkl pq". The first 6 characters of "cmd_string" relate
to the following 6 game commands:
j - left
k - rotate
l - right
<space> - drop
p - pause
q - quit
- j - left
- k - rotate
- l - right
- space - drop
- p - pause
- q - quit
Specifying "cmd_string" allows one to re-define the commands.
The pause command pauses the game, clears the screen and
prints the current score. To un-pause, type the pause
prints the current score. To resume, type the pause
character again, which by default is "p".
As was stated last year, we are likely to be more strict about
portability in the future. [ We mean it this time :-) ]
## Author's remarks
## Author's remarks:
This program plays the familiar game of `TETRIS' with the
following features:
@@ -131,6 +141,7 @@ at the start and -raw at the end. This further reduces the size of
the program, but has the possible disadvantage that the program
can only by stopped by 'q' or by the `kill -9' command.
```c
long h[4];t(){h[3]-=h[3]/3000;setitimer(0,h,0);}c,d,l,v[]={(int)t,0,2},w,s,I,K
=0,i=276,j,k,q[276],Q[276],*n=q,*m,x=17,f[]={7,-13,-12,1,8,-11,-12,-1,9,-1,1,
12,3,-13,-12,-1,12,-1,11,1,15,-1,13,1,18,-1,1,2,0,-12,-1,11,1,-12,1,13,10,-12,
@@ -150,6 +161,7 @@ can only by stopped by 'q' or by the `kill -9' command.
0);while(getchar()-a[4]);puts("\033[H\033[J\033[7m");sigsetmask(s);}}d=popen(
"stty -cbreak echo stop \023;sort -mnr -o HI - HI;cat HI","w");fprintf(d,
"%4d from level %1d by %s\n",w,l,getlogin());pclose(d);}
```
## Copyright and CC BY-SA 4.0 License:
+14 -10
View File
@@ -1,21 +1,25 @@
## Best one liner
David Van Brackle
Department of Computer Science
University of Central Florida
Orlando, Florida
32816
USA
David Van Brackle
Department of Computer Science
University of Central Florida
Orlando, Florida
32816
US
## To build:
make all
```sh
make all
```
## Try:
./vanb the rug gary lent
./vanb unix is better than os/2
```sh
./vanb the rug gary lent
./vanb unix is better than os/2
```
## Judges' remarks:
@@ -25,7 +29,7 @@ element on each line, followed by a line of ten dashes.
## Selected notes from the author:
## Author's remarks:
The program has the following charming and possibly
non-portable features:
+69 -48
View File
@@ -1,23 +1,24 @@
# Most algorithms in one program
Merlyn LeRoy (Brian Westley)
Starfire Consulting
1026 Blair Ave.
St. Paul, MN
55104
USA
http://www.westley.org
Merlyn LeRoy (Brian Westley)
Starfire Consulting
1026 Blair Ave.
St. Paul, MN
55104
US
<http://www.westley.org>
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) was able to get
this to partially work with clang; clang requires that the second, third and
fourth args to main() be `char **`. Only `westley.c` and `ver0.c` (see below) will
compile with clang. It's possible to get ver1.c to compile too but this causes
compile with clang. It's possible to get `ver1.c` to compile too but this causes
problems with generating the output of the remaining files so we have opted, at
least for now, to not do that, as it does not have to output just source code.
He notes that the original source code sometimes segfaults with `ver2` which
@@ -28,31 +29,32 @@ Thank you Cody for your help!
## Try:
./westley < westley.c > ver0.c
./westley 1 < westley.c > ver1.c
./westley 1 2 < westley.c > ver2.c
./westley 1 2 3 < westley.c > ver3.c
```sh
./westley < westley.c > ver0.c
./westley 1 < westley.c > ver1.c
./westley 1 2 < westley.c > ver2.c
./westley 1 2 3 < westley.c > ver3.c
```
Try compiling and running the 4 resulting programs. To compile try:
make ver0
make ver1
make ver2
make ver3
```sh
make ver0
make ver1
make ver2
make ver3
```
## Judges notes:
## Judges' remarks:
There is a secret way to get ONE of the versions to print out
"Hello, world!\n". Can you find how to do it?
## Selected notes from the author:
## Author's remarks:
This is a filter. If it is run with no arguments, it copies
stdin to stdout. With one argument, it ROT13's stdin to
@@ -63,42 +65,44 @@ Also requires two's complement (I think).
The source code will run if ROT13'ed and/or reversed, using a
different algorithm for each version (hereafter referred to as
ver0 (original), ver1 (ROT13), ver2 (reversed), and ver3
`ver0` (original), `ver1` (ROT13), `ver2` (reversed), and `ver3`
(ROT13 and reversed)).
When compiling these versions, one needs to define 'trgpune'
in the compile line (which the Makefile now has). Example:
cc -Dtrgpune=putchar ver3.c -o ver3
```sh
cc -Dtrgpune=putchar ver3.c -o ver3
```
"trgpune" is the ROT13 of getchar(), so getchar() and putchar()
`trgpune` is the ROT13 of `getchar()`, so `getchar()` and `putchar()`
are exchanged in the ROT13 counterpart. It is easy to see that
this is unavoidable. I must have a #define for a library
this is unavoidable. I must have a `#define` for a library
function; otherwise I would have an unidentified extern for the
ROT13 version. If I then define this function, it won't link
in the library version for the ORIGINAL code, since my
definition will supersede the library function. Hence, the
compiler option gives me putchar(), and allows me to use
getchar(). I pass a dummy argument to getchar() to eliminate
compiler option gives me `putchar()`, and allows me to use
`getchar()`. I pass a dummy argument to `getchar()` to eliminate
"variable number of args" from lint (unless it checks against
the library). Otherwise, all versions lint reasonably (main
returns random value & constant in conditional context [when I
check for ROT13 version] is all it complains about).
ver0 and ver1 use a range check and a calculation to do ROT13,
while ver2 and ver3 use table lookup. All versions contain
main() and it's ROT13 fn, znva(). ver0/ver1 [ver2/ver3] are
`ver0` and `ver1` use a range check and a calculation to do ROT13,
while `ver2` and `ver3` use table lookup. All versions contain
`main()` and it's ROT13 fn, `znva()`. `ver0`/`ver1` [`ver2`/`ver3`] are
(of course) syntactically identical, since the syntax is in the
non-alphabetic characters. However, since one program starts
at main() while it's ROT13 counterpart starts at znva(), znva()
calls main (znva() is also used for output).
at `main()` while it's ROT13 counterpart starts at `znva()`, `znva()`
calls main (`znva()` is also used for output).
All versions use recursion to work. If the program is NOT
reversing it's output, it prints out the (possibly ROT13'd)
character before recursing, otherwise it prints it out
afterward (or doesn't recurse at all when EOF is reached).
Since most of this code is identical, it is put into znva() and
called with a first parameter of 0 as a flag (as "main()", it's
Since most of this code is identical, it is put into `znva()` and
called with a first parameter of 0 as a flag (as `main()`, it's
first argument (argc) must be at least one).
I can't use any flow control. If I used if(), I would have a
@@ -106,45 +110,62 @@ function vs() to define in the ROT13 version. But a function
called vs() turns into a function called if() in the original,
so it can't be done. Therefore, I do:
expr1 && expr2 && (expr3=etc);
```c
expr1 && expr2 && (expr3=etc);
```
which is the same as:
if (expr1 && expr2) expr3=etc;
```c
if (expr1 && expr2) expr3=etc;
```
A/UX on the Macintosh doesn't get this right; it evaluates ALL
expressions if they aren't in an assignment or conditional
statement. This might warrant a warning, since other compilers
may do this. I found MANY compilers botched:
expr1 && (expr2,expr3);
```c
expr1 && (expr2,expr3);
```
expr2 was OFTEN evaluated even if expr1 was false. I removed
`expr2` was OFTEN evaluated even if `expr1` was false. I removed
such statements to make it more portable.
The variable names are worth noting:
'irk' and 'vex' are ROT13 pairs and are synonyms.
'Near' and 'Arne' are ROT13 pairs and are anagrams.
'NOON' and 'ABBA' are ROT13 pairs and are palindromes.
'tang' and 'gnat' are both ROT13 and palindrome pairs!
--
'irk' and 'vex' are ROT13 pairs and are synonyms.
'Near' and 'Arne' are ROT13 pairs and are anagrams.
'NOON' and 'ABBA' are ROT13 pairs and are palindromes.
'tang' and 'gnat' are both ROT13 and palindrome pairs!
--
Normally (!), a reversible C program is done thus:
/**/ forward code /*/ edoc drawkcab /**/
```c
/**/ forward code /*/ edoc drawkcab /**/
```
If your compiler nests comments, it will get this wrong.
However, I have made some bits of the code palindromic,
(or different, but reversible) so it is more like:
/**/forward/*//**/ palindromic /**//*/drawkcab/**/
```c
/**/forward/*//**/ palindromic /**//*/drawkcab/**/
```
The code can therefore be interlaced. There are eight
such palindromic bits. You can find them within the
`/*//**/ /**//*/` pairs.
The body of the code of ver0 and ver1 is a large lumpy 'K' (for
Kernighan); the code of ver2 and ver3 is a flat-topped and
The body of the code of `ver0` and `ver1` is a large lumpy 'K' (for
Kernighan); the code of `ver2` and `ver3` is a flat-topped and
lumpier 'R' (for Ritchie). Judicious use of spaces and tabs
helped here. It barely fits on an 80x24 screen. Squint. Note
that the code must start with a blank line, or the reversed version
+1
View File
@@ -1 +1,2 @@
baruch
baruch.alt
+6
View File
@@ -0,0 +1,6 @@
int v,i,j,k,l,s,a[99];
int main(void)
{
for(scanf("%d",&s);*a-s;v=a[j*=v]-a[i],k=i<s,j+=(v=j<s&&(!k&&!!printf(2+"\n\n%c"-(!l<<!j)," #Q"[l^v?(l^j)&1:2])&&++l||a[i]<s&&v&&v-i+j&&v+i-j))&&!(l%=s),v||(i==j?a[i+=k]=0:++a[i])>=s*k&&++a[--i])
;puts("");
}
+5 -4
View File
@@ -4,7 +4,7 @@ Chris Mills
Wyse Technology
3471 N. 1st St.
San Jose CA 95134
USA
US
## To build:
@@ -12,7 +12,7 @@ USA
make all
```
## To run
## To run:
```sh
./cmills [starting_cash]
@@ -23,8 +23,9 @@ work in modern systems (it resulted in a bus error otherwise). Thank you Yusuke
for your assistance!
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this safer by
using `fgets()` instead of `gets()`. This avoids a potentially alarming warning
at compiling and/or linking and/or runtime. Thank you Cody for your assistance!
using `fgets()` instead of `gets()`. This avoids an annoying and potentially
alarming warning at compiling and/or linking and/or runtime that in some cases
is interspersed with the program's output. Thank you Cody for your assistance!
For the original code see the [1992 archive](/archive/archive-1990.tar.bz2).
+7 -5
View File
@@ -5,11 +5,13 @@ Imperial College, University of London
Myrsinis 1
GR-145 62 Kifissia
Greece
<https://www.spinellis.gr/>
<https://www.spinellis.gr/>
## To build:
make all
```sh
make all
```
[Yusuke Endoh](/winners.html#Yusuke_Endoh) fixed this for modern systems. Thank
@@ -17,10 +19,10 @@ you Yusuke!
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) removed the erroneous
prototype to `fopen()` and made this use `fgets()` instead of `gets()` to make
it safer and to prevent a potentially alarming warning at compiling and/or
linking and/or runtime. Thank you Cody for your assistance!
it safer and to prevent an annoying and potentially alarming warning at
compiling and/or linking and/or runtime. Thank you Cody for your assistance!
## To run
## To run:
```sh
./dds
+1 -1
View File
@@ -4,7 +4,7 @@ David Goodenough
anonymous organization
541 Commonwealth Ave
Newton, MA 02159
USA
US
## To build:
+6 -6
View File
@@ -5,19 +5,19 @@ Research Institute for Advanced Computer Science
MS 230-5
NASA Ames Research Center
Moffett Field, CA 94131
USA
US
Karl F. Fox
Morning Star Technologies, Inc.
1760 Zollinger Road
Columbus, OH 43221
USA
US
Paul Eggert
Twin Sun Inc.
360 N. Sepulveda Blvd. #2055
El Segundo, CA 90245
USA
US
## To build:
@@ -27,7 +27,7 @@ make all
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the script to
work properly in modern environments (to do with PATH not having '.' in it). He
notes that with an invocation in the try section below you will with macOS get
notes that with an invocation in the try section below will with macOS show
what appears to be an error message but is actually okay. He gives more
information in the [bugs.md](/bugs.md) file. Thank you Cody for the help and
notes!
@@ -136,7 +136,7 @@ environment.
----------------------------------------------
### Portability:
### Portability
We have ported this program to a wide variety of systems. Among
these are:
@@ -152,7 +152,7 @@ these are:
- Dynix / Sequent Balance ('cc' for Natl. Semi. base + 'gcc 1.36')
- Unicos / Cray 2
### Obfuscation:
### Obfuscation
We (the authors) feel this program is obfuscated for the
following reasons:
+2
View File
@@ -51,6 +51,8 @@ to functions!
## Author's remarks:
Rot13:
Vg vf fvzcyr gb znxr gur cebtenz cevag bgure fgevatf. Rnpu
nycunorgvpny punenpgre sebz n gb m vf cevagrq bhg nf vgf
bccbfvgr:
+1 -1
View File
@@ -4,7 +4,7 @@ Larry Jones
SDRC
2000 Eastman Dr
Milford, OH 45150
USA
US
## To build:
+2 -2
View File
@@ -4,13 +4,13 @@ Byron Rakitzis
Princeton University
5707 Old Lodge Dr.
Houston, TX 77066
USA
US
Sean Dorward
Princeton University
10274 Burleigh Cottage Lane
Ellicott City, MD 21043
USA
US
## To build:
+19 -16
View File
@@ -4,7 +4,7 @@ Adrian Mariano
University of Washington
2729 72nd Ave SE
Mercer Island, WA 98040
USA
US
## To build:
@@ -21,9 +21,9 @@ that dump core when NULL is dereferenced but this problem showed itself in
modern systems even with the 4 '0 0 0 0'. He also fixed a segfault if not enough
args are specified and fixed the code so that the generated `fibonacci.c`
actually works; before it just printed `0` over and over again (since it did not
work anyway a segfault prevention was added here). He also some array addressing
(some of which might not be strictly necessary but as he was testing the
`fibonacci.c` bug he ended up changing it anyway). Finally he changed this
work anyway a segfault prevention was added here). He also fixed some array
addressing (some of which might not be strictly necessary but as he was testing
the `fibonacci.c` bug he ended up changing it anyway). Finally he changed this
program to use `fgets()` not `gets()` to make it safer and to prevent a warning
about `gets()` at linking or runtime. Thank you Cody for your assistance!
@@ -40,12 +40,13 @@ initially. Thank you Yusuke!
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)
```
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:
@@ -65,15 +66,17 @@ The program's source implements four functions, all from the
same source file!
When you compile theorem.c as is and run with 5 args, it numerically
solves the equation y'=f(x,y), with a step size of h, over the interval
x=[x1,x2], with the initial condition of y(x1)=y1.
solves the equation `y'=f(x,y)`, with a step size of `h`, over the interval
`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
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
left to right. (i.e., parenthesis aren't supported).
@@ -128,7 +131,7 @@ received a standing ovation; a first for a contest entry.
## Author's remarks:
Differential equations are solved via the Runge-Kutta method, which guarantees
local error proportional to h^5, and total error across a finite interval is at
local error proportional to `h^5`, and total error across a finite interval is at
most a constant times `h^4`.
Sorting is accomplished with a standard shell sort.
+9 -8
View File
@@ -4,7 +4,7 @@ Brian Westley (Merlyn LeRoy on usenet)
DigiBoard, Inc.
1026 Blair Ave.
St. Paul, MN 55104
USA
US
<http://www.westley.org>
## To build:
@@ -55,18 +55,19 @@ Use `westley.alt` as you would `westley`.
## Judges' remarks:
If you would rather "Daisy" someone other than Westley, rename
the program as needed. :-)
Read each block of code as if it were a piece of correspondence.
For example, the first block of code would read:
charlie,
doubletime me, OXFACE!
not interested, get out
mainly die, charly, *die*
signed charlotte
```
charlie,
doubletime me, OXFACE!
not interested, get out
mainly die, charly, *die*
signed charlotte
```
The original source had control-L's after each code block. To
make it easier on news readers, we converted each control-L to
@@ -86,7 +87,7 @@ Lint complains about everything - null effect, xxx may be used before
set, statement not reached, return(e) and return. Lint dumps core
on some systems. My personal favorite lint complaint is
"warning: eroticism unused in function main".
**_"warning: eroticism unused in function main"._**
Also obviously, `(char)lotte` and `(char*)lie` are incompatible types...
+4 -4
View File
@@ -54,7 +54,7 @@ Carriage return is mapped to newline on input and ignored on output. Tab stops
are every eight columns. Non-printable characters may have unpredictable
results depending on the implementation of `curses`.
### COMMANDS:
### Commands
- h j k l left, down, up, right cursor movement
- H J K L word left, page down, page up, word right
@@ -66,13 +66,13 @@ results depending on the implementation of `curses`.
- R refresh the screen
- Q quit
### EXIT STATUS:
### Exit status
- 0 success
- 2 missing edit filename
### ABOUT THIS ENTRY:
### About this entry
The BUF size should be set at compile time to 32767. This value was used
because the Sozobon C compiler for the Atari ST has 16 bit ints and a limit on
@@ -102,7 +102,7 @@ in the same group every so often.
This entry will display a file with long lines, but has trouble scrolling the
screen with long lines. Paging up and down should work correctly, however.
### REFERENCES:
### References:
[Fin80] Craig A. Finseth, "Theory and Practice of Text Editors or
A Cookbook For An EMACS", TM-165, MIT Lab. for Computer
+3 -3
View File
@@ -77,7 +77,7 @@ Here, then, is the SORTA programming language. All non-digits delimit
numeric constants. Spaces and newlines are ignored except as numeric
delimiters.
### Basic operations:
### Basic operations
- `q`: quit
- `number`: push that number on top of the i stack
@@ -107,7 +107,7 @@ delimiters.
Note that nand is sufficient to construct all bitwise operations, as
demonstrated by icalc below.
### System operations:
### System operations
- `o`: pop top of `s stack` and top two of `i stack`; `open(s1,i2,i1);` leave
result on `i stack`
@@ -126,7 +126,7 @@ in the s stack to terminate the argument list. If the execve()
fails, any operation involving current members of the s stack has
undefined effects, and -1 is pushed onto the i stack.
### High-level language operations:
### High-level language operations
- :x: copy the top of the s stack into a program labeled by character x
- =x: pop the top of the i stack. If it was nonzero, execute the program
+8 -4
View File
@@ -4,7 +4,7 @@ Sean Barrett
University of Maryland
5407 20th Place
Hyattsville MD 20782
USA
US
## To build:
@@ -26,7 +26,7 @@ You are invited to try to cheat, ... if you can figure out how! :-)
## Author's remarks:
### HOW TO PLAY:
### How to play
When the game starts, you are at the far end of the maze from the
exit, looking down a corridor. To move forward, type `f` and press
@@ -37,7 +37,9 @@ after all the moves.
The game ends if you get out the exit (you'll know it when you see
it) or when you type `^D` (EOF).
### HINTS ON HOW TO CHEAT: (rot13 to read)
### Hints on how to cheat
Rot13 to read:
Lbh pna, bs pbhefr, purng ol ybbxvat ng gur znmr znc. Gur dhrfgvba
lbh arrq gb nfx lbhefrys, gubhtu, vf jung frdhrapr bs punenpgref
@@ -48,7 +50,9 @@ it) or when you type `^D` (EOF).
gura onpxjneq sebz gur pheerag cbfvgvba gb qenj gur yrsg fvqr naq
gura gur evtug fvqr.
### ADVANCED USAGE NOTES: (rot13 to read)
### Advanced usage notes
Rot13 to read:
Gur cebtenz pna nyfb or eha sebz bgure svyrf pbagnvavat znmrf. Gur
znmr fubhyq or ynvq bhg tencuvpnyyl va gur boivbhf sbezng; arjyvarf
+3 -3
View File
@@ -23,9 +23,9 @@ make all
Why is the following label necessary?
sorryfor_this_unused_but_very_needed_label:
```c
sorryfor_this_unused_but_very_needed_label:
```
Notice that if you C beautify (cb) or pre-process this program, it
will no longer work correctly, or at all. (go ahead, try it... :-))
+2 -2
View File
@@ -4,14 +4,14 @@ David Applegate
School of Computer Science
Carnegie Mellon University
Pittsburgh PA 15213
USA
US
Guy Jacobson
AT&T Bell Laboratories
600 Mountain Avenue
Murray Hill NJ 07974
USA
US
## To build:
+43 -26
View File
@@ -16,35 +16,51 @@ make all
## To run:
```sh
./dds basic_program
./a.out
./dds basic_program 2>/dev/null
./a.out 2>/dev/null
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed some segfaults in
this entry as well as making it so `a` (was `a.out`, see below) can be generated
(as in the program did not work, at least with clang). The alternative code,
described below, is what is needed for clang. Reading it might be instructive
even if you have gcc.
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault that
prevented this entry from working at all and made an alternate version
that works with `clang`. The alternate code, described below, is what is needed
for clang. Reading it might be instructive even if you have gcc.
The first segfault which was always triggered was due to the code `*q>'
'&&(*q)--;`. This seems odd at first glance but it's pointing to `s` which was
read-only memory as a `char *s`. It's now a `char s[]`. The second and third
segfaults were caused if a file was not specified (or it the one specified did
not exist or couldn't be opened for some reason) and if the output file could
not be opened for writing.
The segfault which was always triggered was due to the code `*q>' '&&(*q)--;`.
This seems odd at first glance but it's pointing to `s` which was read-only
memory as a `char *s`. It's now a `char s[]`.
Thank you Cody for your assistance!
### INABIAF - it's not a bug it's a feature! :-)
Please note that if the BASIC file cannot be opened for reading or the output
file cannot be opened for writing then this program will crash. These crashes
are a mild nuisance but are considered a feature not a bug. We challenge you to
fix it for learning if you wish. See also [bugs.md](/bugs.md).
## Try:
With gcc, make and run as follows:
make dds
```sh
make dds
```
For example, the author suggests trying:
./dds LANDER.BAS
./a.out
```sh
./dds LANDER.BAS 2>/dev/null
./a.out 2>/dev/null
```
What happens if you give the program a C program like itself? Try:
```sh
./dds dds.c 2>/dev/null
```
You'll get errors yes but what does the generated file look like? What about
other types of files?
### Alternative code:
@@ -55,12 +71,13 @@ not messing with the `s` string which is quite complicated. For all Cody knows
even changing the length could break functionality and indeed the length would
have to be longer for this to work with clang.
How does it work? The code, which you will see in `dds.c`, `return system(q-6);`
equates to `return system("cc a.c");` but clang by default, at least in macOS,
has default -Werror and there were some warnings. This means that the
compilation failed with clang. In particular it would fail (at least with
`LANDER.BAS`) due to a return from `main()` without a return value and the use
of functions not yet declared.
How does it work? The code (which you will see in [dds.c](dds.c)) does a `return
system(q-6);` which equates to `return system("cc a.c");` but clang by default,
at least in macOS, has default -Werror and there were some warnings. This means
that the compilation failed with clang (because it didn't use `make` so no
[Makefile](Makefile) was used). In particular it would fail (at least with
[LANDER.BAS](LANDER.BAS)) due to a return from `main()` without a return value
and the use of functions not yet declared.
Now as noted since the string `s` is complicated and because Cody did not want
to inadvertently mess something up he changed that code to `system("make a");`
@@ -72,8 +89,8 @@ version:
```sh
make clobber alt
./dds.alt LANDER.BAS
./a
./dds.alt LANDER.BAS 2>/dev/null
./a 2>/dev/null
```
Thank you Cody for your assistance!
+5 -5
View File
@@ -10,8 +10,8 @@ R%PN4\nQ<g\\(aP3Q(^>aP2Q,2<n\\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n\
aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\
P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!b/d";int k;char R[4][99]
;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v
[1],"r"),*o=fopen(q-3,"w");if(!i||!o)return 1;for(p=s;;p++)switch(*p++){B'M':
Q(k=fgetc(i))!=EOF&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return
system("make a");}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);
p--B'C':k=0;Q k<*p-'0')(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G
B'G':k= *p;G:p=s;while(*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}}
[1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF
&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system("make a");}*r=0
B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0'
)(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G':k= *p;G:p=s;while(
*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}}
+5 -5
View File
@@ -10,8 +10,8 @@ R%PN4\nQ<g\\(aP3Q(^>aP2Q,2<n\\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n\
aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\
P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!b/d";int k;char R[4][99]
;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v
[1],"r"),*o=fopen(q-3,"w");if(!i||!o)return 1;for(p=s;;p++)switch(*p++){B'M':
Q(k=fgetc(i))!=EOF&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return
system(q-6);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);
p--B'C':k=0;Q k<*p-'0')(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G
B'G':k= *p;G:p=s;while(*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}}
[1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF
&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system(q-6);}*r=0
B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0'
)(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G':k= *p;G:p=s;while(
*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}}
+4 -4
View File
@@ -5,7 +5,7 @@ Ohio State University
Department of Computer and Information Science
2036 Neil Avenue Mall
Columbus, Ohio 43210
USA
US
## To build:
@@ -37,8 +37,8 @@ Read the last line backwards! Credit goes to [Merlyn LeRoy (Brian
Westley)](/winners.html#Brian_Westley) for that. See his 22 August 1992
[rec.puzzles
post](https://groups.google.com/g/rec.puzzles/c/z_xVPMRVBtg/m/lyEYSAeBD4gJ). To
those who have a harder time reading backwards it says: `Gary lent the rug`
from `the rug gary lent`!
those who have a harder time reading backwards it says: `Gary lent the rug`,
rotated from `the rug gary lent`!
## Judges' remarks:
@@ -54,7 +54,7 @@ How does this program work? Which 3 bytes of C code can be changed
into 2 bytes, allowing the program to still work, but also stripping
the high bit off of some input?
## Author's remarks
## Author's remarks:
The author wishes to thank J Greely for the last 6 bytes.
+1 -1
View File
@@ -4,7 +4,7 @@ Brian Westley (Merlyn LeRoy on usenet)
DigiBoard, Inc.
1026 Blair Ave.
St. Paul, MN 55104
USA
US
<http://www.westley.org>
## To build:
+11 -11
View File
@@ -4,7 +4,7 @@ Adrian Mariano
University of Washington
2729 72nd Ave SE
Mercer Island, WA 98040
USA
US
## To build:
@@ -15,16 +15,16 @@ make all
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) changed the location
that it used `gets()` to be `fgets()` instead to make it safer and to prevent
any warnings during linking or runtime. One might think that simply changing the
gets() to fgets() (with stdin) would work but it did not because `fgets()`
stores the newline and `gets()` does not. The code was relying on not having
this newline. With `fgets()` the code `if(A(Y)) puts(Y);` ended up printing an
extra line which made the generation of some files (like `adhead.c`) fail to
compile (`gets()` does not store the newline but `fgets()` does). Why? There was
a blank line after a `\` at the end of the first line of a macro definition!
Thus the code now first trims off the last character of the buffer read to get
the same correct functionality but in a safe way. Thank you Cody for your
assistance!
annoying warnings during compiling, linking or runtime (interspersed with the
program's output). One might think that simply changing the gets() to fgets()
(with stdin) would work but it did not because `fgets()` stores the newline and
`gets()` does not. The code was relying on not having this newline. With
`fgets()` the code `if(A(Y)) puts(Y);` ended up printing an extra line which
made the generation of some files (like `adhead.c`) fail to compile (`gets()`
does not store the newline but `fgets()` does). Why? There was a blank line
after a `\` at the end of the first line of a macro definition! Thus the code
now first trims off the last character of the buffer read to get the same
correct functionality but in a safe way. Thank you Cody for your assistance!
## Try:
+3 -3
View File
@@ -47,8 +47,8 @@ Both albert and albert.orig loop without printing anything, although
the first factor is 101 and is usually found in an instant.
```
The `albert.c` file is the fixed file, whereas the `albert.alt.c`
is the file before applying Leo Broukhis' fix.
The [albert.c](albert.c) file is the fixed file, whereas the
[albert.alt.c](albert.alt.c) is the file before applying Leo Broukhis' fix.
To compile this alternate version:
@@ -119,7 +119,7 @@ destroy some of the lay out. Running the program through lint shows the usual
remarks for a K&R program. Defeating this through casts does not make a program
cleaner in my opinion.
### Hints:
### Hints
Here are some hints, but they may not be too helpful:
+10 -10
View File
@@ -4,7 +4,7 @@ Sean Barrett
Software Construction Company
430 Southwest Parkway, #1906
College Station, TX 77840
USA
US
## To build:
@@ -13,7 +13,7 @@ USA
make all
```
## To run
## To run:
```sh
./buzzard.1 num num
@@ -52,13 +52,13 @@ What you shouldn't think about `buzzard.1`:
I didn't just submit the post-C-preprocessed output as an entry.
#### Cute trick warning:
#### Cute trick warning
`buzzard.1` contains only a numeric printf, yet sometimes it prints out
short strings.
### What it does:
### What it does
`buzzard.1` is a simple mathematical program. It expects two numeric
arguments.
@@ -86,7 +86,7 @@ If the first argument is less than 0, it prints out an
error message.
### What it is:
### What it is
`buzzard.1` is a translator from a pseudo-assembly language into a subset of C
suitable for execution on Charles Babbage's Analytical Engine. Or rather, the
@@ -100,22 +100,22 @@ could have been simulated on the AE by connecting the already-processed card
stack to the input card stack.
### How to try to understand it:
### How to try to understand it
*Don't* expand the `#define`s! Rather, decipher what they do.
Some of them are mere obfuscation fodder, put in to encourage
you to run it through CPP.
### What it doesn't quite do right as an emulator:
### What it doesn't quite do right as an emulator
Because of the definitional constraints, calls to `atoi(argv[#])` also appear
inside the loop. These could be put outside-- the initial values of the
inside the loop. These could be put outside--the initial values of the
"registers" on the AE--but the macro conventions being used didn't lend
themselves to it.
### Theoretical observations:
### Theoretical observations
The simulated comparison operations only work with a certain range of numbers;
numbers that are too large will cause the output code to fail to simulate the
@@ -130,7 +130,7 @@ simulate any existing machine--although not quickly). This would be a good
place to site some references on the AE, but I don't have any.
### Definition of the input language to buzzard.1 (OR What Exactly Do All The Macros Do?):
### Definition of the input language to buzzard.1 (OR What Exactly Do All The Macros Do?)
[Don't read this unless you're stumped!]
+4 -4
View File
@@ -4,7 +4,7 @@ Sean Barrett
Software Construction Company
430 Southwest Parkway, #1906
College Station, TX 77840
USA
US
## To build:
@@ -67,7 +67,7 @@ Have fun!
## Author's remarks:
### What it does:
### What it does
`first` implements a relatively primitive stack machine. How
primitive? It supplies 13 visible primitives: 3 arithmetic,
@@ -88,7 +88,7 @@ are below, and the interesting property is discussed much
further down.
### How to run it:
### How to run it
`first` expects you to first enter the names of the 13 primitives,
separated by whitespace--it doesn't care what you name them, but
@@ -129,7 +129,7 @@ reimplementing all of first and third a second time--I did not care to tackle
this project.
### Compiling:
### Compiling
`first` is reasonably portable. You may need to adjust the size of the buffers
on smaller machines; `m[]` needs to be at least 2000 long, though.
+8 -8
View File
@@ -40,10 +40,10 @@ Determine where your system dictionary is located. You may find
it located in one of the following places:
```
/usr/share/dict/words
/usr/share/lib/spell/words
/usr/ucblib/dict/words
/dev/null # <-- for machines with nothing to say
/usr/share/dict/words
/usr/share/lib/spell/words
/usr/ucblib/dict/words
/dev/null # <-- for machines with nothing to say
```
Then using the proper dictionary:
@@ -83,13 +83,13 @@ construed to mean Alphabet Game, and by pure coincidence it happens to be the
author's initials.
### What it does:
### What it does
AG takes one or more words as arguments, and tries to find anagrams of those
words, i.e. words or sentences containing exactly the same letters.
### How to use it:
### How to use it
To run AG, you need a dictionary file consisting of distinct words in the
natural language of your choice, one word on each line. If your machine doesn't
@@ -113,7 +113,7 @@ number of words in the anagrams is limited to 3 by default. This
limit can be changed using a numeric command line option, as in
`./ag -4 international obfuscated c code contest </usr/dict/words`.
### Bugs:
### Bugs
- There is no error checking.
- Standard input must be seekable, so you can't pipe the dictionary into AG.
@@ -126,7 +126,7 @@ it can solve is severely limited on machines that limit the stack size to 64k or
less.
### Obfuscatory notes:
### Obfuscatory notes
As you can see, AG takes advantage of the new '92 whitespace rules to
achieve a clear, readable, self-documenting layout. The identifiers
+2
View File
@@ -1 +1,3 @@
imc
screen1.ras
screen2.ras
+3 -3
View File
@@ -37,7 +37,7 @@ modified to avoid this problem.
## Author's remarks:
### Portability:
### Portability
This program depends upon the ASCII character set, and makes certain
assumptions about the architecture. It naughtily declares the first
@@ -117,7 +117,7 @@ appears before `t`, specifying an option without numbers has no effect.
(specifying `-s -t` has the effect of producing text with the default
raster size; not a good idea!).
### Options:
### Options
The options of this program are:
@@ -155,7 +155,7 @@ bits (e.g. 8).
While the program is creating your picture, it displays dots on the
standard error to indicate its progress (one dot per pixel line).
### Example pictures to try:
### Example pictures to try
Here are a couple of good pictures to draw:
+8 -8
View File
@@ -62,9 +62,9 @@ directory, assumed that exit returned a value which cause problems for some
systems where exit returns void. The file [kivinen.c](kivinen.c) avoids this problem.
## Selected notes from the author:
## Author's remarks:
### X Entertainment Kit:
### X Entertainment Kit
This kit includes three games from the early of video games for
The X Window System Version 11 Release 5. It should work with
@@ -79,7 +79,7 @@ of aliens touches the ground, or destroy you. To win the game you
must destroy all the aliens. If you evade out from the screen you
lose.
##### Controls:
##### Controls
- Button 1 = Move left
- Button 2 = Fire missile
@@ -91,7 +91,7 @@ lose.
Break all the bricks with the ball, using your paddle. If you miss
the ball the game ends.
##### Controls:
##### Controls
- Button 1 = Move left
- Button 3 = Move right
@@ -102,14 +102,14 @@ the ball the game ends.
Catch all the falling pieces, before they reach the ground. If you
miss it, game ends. To win you must catch all 30 pieces.
##### Controls:
##### Controls
- Button 1 = Move left
- Button 3 = Move right
### Starting a game:
### Starting a game
The type of the game is determined by the number of arguments
given to the program.
@@ -126,13 +126,13 @@ given to the program.
...and so on...
### Scores:
### Scores
The exit value of the game is your score. The smaller the score
the better it is. The exit value of zero means you have won.
### Features:
### Features
The game has a cheat system, which can be found after examining the
event loop at the end of program. It is not a bug, it's a feature!
+5 -4
View File
@@ -4,7 +4,7 @@ Ed Luke
Mississippi State University
P.O. Box 6176
Mississippi State, MS 39762
USA
US
## To build:
@@ -24,9 +24,10 @@ work with gcc. Due to how it works (see Judges' remarks below) this will not
work with clang. Thank you Yusuke!
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made it use `fgets()`
instead of `gets()` and also added the `runme.sh` script to demonstrate it
(using make was problematic). Cody notes that unfortunately this does not work
with clang due to different compiler messages. Thank you Cody!
instead of `gets()` to prevent annoying warnings getting in the way and also
added the `runme.sh` script to demonstrate it (using make was problematic). Cody
notes that unfortunately this does not work with clang due to different compiler
messages. Thank you Cody!
For the original entry see the [archive tarball](/archive/archive-1992.tar.bz2).
+2 -1
View File
@@ -30,7 +30,8 @@ NOTE: Some systems need to compile with `-ltermcap` as well as `-lcurses`.
NOTE: The original winning source `marangon.orig.c`, found in the archive
directory, assumed that exit returns a value which cause problems for some
systems where exit returns a void. The file `marangon.c` avoids this problem.
systems where exit returns a void. The file [marangon.c](marangon.c) avoids
this problem.
## Author's remarks:
+5 -5
View File
@@ -13,7 +13,7 @@ UK BS12 4SQ
make all
```
## To run
## To run:
```sh
./nathan
@@ -58,7 +58,7 @@ The US International Traffic in Arms Regulations controls certain exportations
going out of the United States. The U.S. Munitions List gives the specific
categories of restricted exports. Because this entry at one time appeared to
fall under this restricted category, the judges originally were not able to
distribute winners outside of the USA.
distribute winners outside of the US.
Nathan Sidwell stated that he was willing to distribute the winning source. To
read HIS instructions of how to obtain his winning program one was able to run:
@@ -84,7 +84,7 @@ re-distribute a program contest winner to the network!
## Author's remarks
### PROGRAM USE:
### Program use
This program is a hello world text encryptor/decryptor. It uses an
enigma (I think) style encryption algorithm, where the encryption
@@ -100,7 +100,7 @@ before the key. (Actually encryption and decryption proper inverse
operations, so you can use decrypt to scramble and encrypt to
descramble, if you're perverse.)
### PORTABILITY (A little knowledge is a dangerous thing):
### Portability (A little knowledge is a dangerous thing)
It's written in ANSI C, and doesn't even assume an ASCII character
set, (it has an array of the characters to convert), so should be
@@ -116,7 +116,7 @@ another scoping level does not need to be opened.
Being an encryptor/decryptor, you probably want the source code to
be obfuscated, to hide the algorithm.
### OBFUSCATION:
### Obfuscation
In spite of the fact that it looks like a nice friendly hello world
program, it isn't (as documented above). (Short lines have been padded,
+12 -12
View File
@@ -6,7 +6,7 @@ Computer Systems Engineering
Bldg. 46A, Room 1123
Lawrence Berkeley Laboratory
1 Cyclotron Rd.
Berkeley, CA 94720 USA
Berkeley, CA 94720 US
## To build:
@@ -110,7 +110,7 @@ blunders but also immediately stupid moves altogether. A ply of 4
will find all mate-in-two's.
### Obfuscation:
### Obfuscation
This program is obfuscated in a number of ways. First, it abuses the
contest rule regarding ';', '{', and '}' in the source not counting
@@ -141,16 +141,16 @@ square on the board. Those moves that are legal it then explores to
see their effects (using alpha-beta search). This tactic somewhat
obfuscates the algorithm used by the program.
Finally, there are three key constants that occur throughout the
program: 64, 8, and 3 (lg 8). Rather than making these available at
compile-time, which provides a hint as to what the program is up to,
they are computed probabilistically at run-time. An instance of the
"Inspection Paradox" is used which happens to produce a value that on
average is close to .64. 10000 instances of this value are computed,
added up, and then divided by 100. Sometimes the value produced will
be 63 or 65 instead of 64 (but I've never observed any other values),
so the result is then rounded to the nearest multiple of 4, and then
the other constants are derived from it.
Finally, there are three key constants that occur throughout the program: 64,
8, and 3 (lg 8). Rather than making these available at compile-time, which
provides a hint as to what the program is up to, they are computed
probabilistically at run-time. An instance of the ["Inspection
Paradox"](https://en.wikipedia.org/wiki/Renewal_theory#Inspection_paradox) is
used which happens to produce a value that on average is close to .64. 10000
instances of this value are computed, added up, and then divided by 100.
Sometimes the value produced will be 63 or 65 instead of 64 (but I've never
observed any other values), so the result is then rounded to the nearest
multiple of 4, and then the other constants are derived from it.
## Copyright and CC BY-SA 4.0 License:
+4 -4
View File
@@ -4,7 +4,7 @@ Brian Westley (aka Merlyn LeRoy)
Digi International
1026 Blair Ave.
St. Paul, MN 55104
USA
US
<http://www.westley.org>
## To build:
@@ -21,7 +21,7 @@ not segfault if not enough args were specified. He did the same for the
alternative version (see below) provided by the author (the original can be seen
in the author's remarks below). Thank you Cody for your assistance!
## To run
## To run:
If lost:
@@ -50,7 +50,7 @@ show correctly!
### Alternative code:
The author provided a version for the USA. To build:
The author provided a version for the US. To build:
```sh
make alt
@@ -143,7 +143,7 @@ is reasonably accurate.
- Beijing 40 116
- Tokyo 36 140
For a domestic (USA) version with higher resolution, try:
For a domestic (US) version with higher resolution, try:
```c
main(l,a,n,d)char**a;{for(d=atoi(a[1])/2*80-atoi(a[2])-2043;
+1 -1
View File
@@ -4,7 +4,7 @@ Chris Mills
Pagine Corporation
1961-A Concourse Drive
San Jose, CA 95131
USA
US
## To build:
+2 -2
View File
@@ -21,7 +21,7 @@ make all
where:
`datafile` is the initial pattern (default: dgibson.data1)
`datafile` is the initial pattern (default: [dgibson.data1](dgibson.data1))
## Try:
@@ -59,7 +59,7 @@ a rectangular grid of cells can be alive or dead, and cells with more
than 3 or less than 2 (out of 8) live neighbours die, and empty cells
with exactly 3 neighbours give birth.
### Some notes:
### Some notes
- the "STAT n" information does not have to be present in the initial
configuration
+36 -30
View File
@@ -1,22 +1,28 @@
# Best Obfuscated Algorithm
E. Jay Berkenbilt
Engineering Research Associates
1595 Springhill Road
Vienna, VA 22182-2235
USA
E. Jay Berkenbilt
Engineering Research Associates
1595 Springhill Road
Vienna, VA 22182-2235
US
## To build:
make all
```sh
make all
```
## To run:
./ejb level
```sh
./ejb level
```
where:
level a value from -128 to 127
```sh
level a value from -128 to 127
```
## Judges' remarks:
@@ -33,20 +39,22 @@ We note that this also works under macOS just fine.
## Author's remarks
WHAT THIS PROGRAM DOES
======================
### What this program does
### Output solution to Towers of Hanoi for five rings:
#### Output solution to Towers of Hanoi for five rings:
./ejb 5
```sh
./ejb 5
```
The format of the output for the Towers of Hanoi case is simply a
text description of how to solve the puzzle.
### Output solution to the Patience puzzle for six rings:
#### Output solution to the Patience puzzle for six rings:
./ejb -6
```sh
./ejb -6
```
For the patience puzzle, the output is a sequence binary codes representing
@@ -55,8 +63,7 @@ A "1" means the ring is on the U; a "0" means it is off the U. The program
prints the word "Invalid" in response to illegal command line parameters.
MOTIVATION
==========
### Motivation
Most people who have written software for other people have been
asked to count lines of code. Naturally, this brings up the
@@ -66,25 +73,24 @@ always provide a meaningful measure of code size. This is
especially true in this program where the number of semicolons
itself is ambiguous. Does it have two or three? In addition, the
only "C" keyword this program uses besides type names and
qualifiers is "return", and the only function defined in the code
is "main". The level of complexity of the program without multiple
qualifiers is `return`, and the only function defined in the code
is `main`. The level of complexity of the program without multiple
semicolons, statements, and functions is achieved by abusing C
operators, especially the comma operator. Considerable use of ||,
&&, and ? : helps too. In addition, main is called recursively.
The null pointer that terminates argv is used to pass additional
operators, especially the comma operator. Considerable use of `||`,
`&&`, and `? :` helps too. In addition, main is called recursively.
The NULL pointer that terminates argv is used to pass additional
information into main. Even though the algorithms used by this
code are simple, this program is still hard to follow even when
indented properly. (It is pretty hard to indent this code
reasonably, however.)
Although this program is has only been tested on UNIX systems but
will probably run on just about any machine with an ANSI C
compiler. It does not use the C preprocessor at all. The only
functions it uses are atoi, malloc, memset, printf, and puts. It
does, however, require that the architecture it runs on have bytes
that are at least eight bits long and pointers that are at least
four bytes long. In addition, it requires an ANSI compiler since
it uses "signed char" and ANSI-style function declarations.
Although this program has only been tested on UNIX systems it will probably run
on just about any machine with an ANSI C compiler. It does not use the C
preprocessor at all. The only functions it uses are `atoi()`, `malloc()`,
`memset()`, `printf()`, and `puts()`. It does, however, require that the
architecture it runs on have bytes that are at least eight bits long and
pointers that are at least four bytes long. In addition, it requires an ANSI
compiler since it uses "signed char" and ANSI-style function declarations.
## Copyright and CC BY-SA 4.0 License:
+13 -9
View File
@@ -1,14 +1,16 @@
# Most Obfuscated X Program
Jon Thingvold
University of Oslo
Sogn Studentby 8231
N 0858 Oslo
Norway
Jon Thingvold
University of Oslo
Sogn Studentby 8231
N 0858 Oslo
Norway
## To build:
make all
```sh
make all
```
NOTE: this entry requires `X11/Xlib.h` header file and the X11 library to
compile. macOS users running Mountain Lion and later will need to download and
@@ -33,11 +35,13 @@ prepended to them. Thank you Yusuke and Cody for your assistance!
## To run:
./jonth # must be run on an X11 server
```sh
./jonth # must be run on an X11 server
```
## Judges' remarks:
Use 'h' and 'l' to shift objects left or right. Use 'k' to
Use `h` and `l` to shift objects left or right. Use `k` to
rotate and press SPACE to drop.
This program's output may be even more obfuscated when played
@@ -52,7 +56,7 @@ This program is also an example of data abstraction. The X array is
after initialization hidden by the well defined macros `t`, `u` and `F`.
This program is highly portable as it runs on a "Notebook" size SPARC.
This program will not work on machines with `sizeof(int)!=sizeof(void *)`.
This program will not work on machines where `sizeof(int)!=sizeof(void *)`.
## Copyright and CC BY-SA 4.0 License:
+2 -2
View File
@@ -114,14 +114,14 @@ DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_TARGET= mind
#################
# build the entry
#################
#
all: data ${TARGET}
all: data ${TARGET} ${ALT_TARGET}
@${TRUE}
.PHONY: all alt data everything clean clobber install \
+52 -41
View File
@@ -1,14 +1,16 @@
# Best Game
Leonid A. Broukhis
Moscow Centre of SPARC Technology
123481 Liberty St.,
89-1-95 Moscow
Russia
Leonid A. Broukhis
Moscow Centre of SPARC Technology
123481 Liberty St.,
89-1-95 Moscow
Russia
## To build:
make all
```sh
make all
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work with
modern compilers. Thank you Cody!
@@ -18,19 +20,23 @@ modern compilers. Thank you Cody!
To have the computer guess:
./leo [colors]
```sh
./leo [colors]
```
To guess the computer's number:
./mind [colors]
```sh
./mind [colors]
```
where:
colors number of possible colors (1 to 15) (default: 6)
[colors] is the number of possible colors (1 to 15) (default: 6)
## Judges' remarks:
By default, the number of colors if 6. You may specify a
By default, the number of colors is 6. You may specify a
value of between 1 and 15 colors. See the author's notes
for instructions of how to play.
@@ -39,8 +45,9 @@ International Internet community.
## Author's remarks:
This program plays mastermind, if you call it by a name ending by
'd', otherwise it _solves_ mastermind. Call it without parameters
This program plays
[Mastermind](https://en.wikipedia.org/wiki/Mastermind_(board_game), if you call it by a name ending by
'd', otherwise it _solves_ Mastermind. Call it without parameters
to use 6 digits (colors), or indicate the number of possible digits
(you cannot change the number of positions so easily).
@@ -48,14 +55,14 @@ The number in parentheses is the number of possible combinations,
based on previous questions and answers. If you solve the puzzle,
"(1)" indicates that your previous moves are enough to give correct
answer. If the program acts as solver and terminates prematurely,
it means that you have mistaken in your answers to its guesses.
it means that you're mistaken in your answers to its question(s).
Question marks indicate the number of digits you have to enter
(either 4 when you guess or 2 when computer guesses).
Note that the program uses the same code for both player and
solver, and the only place where it makes difference is the
solver, and the only place where it makes a difference is the
interactive part. Many obfuscations have been made to achieve
this. An expression giving (bulls * 16 + cows) from two numbers
this. An expression giving `(bulls * 16 + cows)` from two numbers
is, however, quite straightforward :-) , as well as the arithmetic
of binary coded colors-base numbers is.
@@ -66,35 +73,39 @@ backspaces. Do "disable scrolling" on cmdtool or similar emulators.
#### Bugs: Please don't type ^D at the prompt!!
##### EXAMPLE: Suppose we think of 1234:
##### EXAMPLE: Suppose we think of 1234
judges-385> leo
(1296): 6433
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
(160): 5363
?? 02 # both 3's are cows
(21): 4231
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
(2): 4132
?? 13 # 3 is a bull; 1, 2 and 4 are cows
(1): 1234
?? 40 # you may enter everything there
```
judges-385> ./leo
(1296): 6433
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
(160): 5363
?? 02 # both 3's are cows
(21): 4231
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
(2): 4132
?? 13 # 3 is a bull; 1, 2 and 4 are cows
(1): 1234
?? 40 # you may enter everything there
```
##### EXAMPLE: Guess the computer's number:
##### EXAMPLE: Guess the computer's number
judges-387> mind
(1296): ???? 1122 # my strategy isn't the best, just as example
00
(256): ???? 3344
20
(18): ???? 5566
02
(6): ???? 3654
11
(2): ???? 3355
00
(1): ???? 6444
40 # we have guessed the number
```
judges-387> ./mind
(1296): ???? 1122 # my strategy isn't the best, just as example
00
(256): ???? 3344
20
(18): ???? 5566
02
(6): ???? 3654
11
(2): ???? 3355
00
(1): ???? 6444
40 # we have guessed the number
```
## Copyright and CC BY-SA 4.0 License:
+64 -60
View File
@@ -1,9 +1,9 @@
# Most Versatile Source
Jyrki Holopainen
Oy LM Ericsson Ab
SF-02420 Jorvas
Finland
Jyrki Holopainen
Oy LM Ericsson Ab
SF-02420 Jorvas
Finland
## To build:
@@ -17,23 +17,23 @@ option `-inum` with `find` with the delete option after finding the inode with
`ls -li` or else use a GUI to do it. Should you wish to try compiling it you
might see something like:
NOTE: This will not compile when using modern compilers because
it relies on a compiler bug which was fixed in gcc 2.3.3 (a very
long time ago now).
rm -f \"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c
cp lmfjyh.c \"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c
cc -std=gnu90 -Wall -Wextra -pedantic -include stdio.h -O3 \
\"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c -o lmfjyh
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lmfjyh] Error 1
and the bogus file will be:
";main(){puts("Hello World!");}char*C=".c
```sh
$ make all
NOTE: This will not compile when using modern compilers because
it relies on a compiler bug which was fixed in gcc 2.3.3 (a very
long time ago now).
rm -f \"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c
cp lmfjyh.c \"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c
cc -std=gnu90 -Wall -Wextra -pedantic -include stdio.h -O3 \
\"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c -o lmfjyh
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lmfjyh] Error 1
```
and the bogus file will be `";main(){puts("Hello World!");}char*C=".c`.
For an explanation of why this is see the author's remarks.
@@ -41,14 +41,16 @@ For an explanation of why this is see the author's remarks.
If you have gcc < 2.3.3:
./lmfjyh
```sh
./lmfjyh
```
## Judges' remarks:
There's more than one way to get around disk quotas. :-)
## Author's remarks;
## Author's remarks:
"Practical and efficient method of compressing source code".
@@ -61,34 +63,36 @@ best with C-source code.
As an example, I have taken a simple "Hello world!" program
that should be familiar to all C-programmers.
Listing 1. A simple "Hello World" program:
#### Listing 1: A simple "Hello World" program
main()
{
puts("Hello World!");
}
```c
main()
{
puts("Hello World!");
}
```
### Packing method
Normally a file name is used only to identify the file,
but this new revolutionary method introduces a totally new concept:
THE FILE NAME IS THE PROGRAM. There is no need to waste
valuable disk space to store source code. The program is
embedded in the file name, only a minor portion of it
is inside the file.
Normally a file name is used only to identify the file, but this new
revolutionary method introduces a totally new concept: THE FILE NAME IS THE
PROGRAM. There is no need to waste valuable disk space to store source code. The
program is embedded in the file name, only a minor portion of it is inside the
file.
Listing 2. Compressed "Hello world":
#### Listing 2: Compressed "Hello world"
char*_=__FILE__;
```c
char*_=__FILE__;
```
Listing 3. Code embedded in the file name:
#### Listing 3: Code embedded in the file name
";main(){puts("Hello World!");}char*C=".c
```c
";main(){puts("Hello World!");}char*C=".c
```
The sample program in listing 1 is 36 bytes long. By using the new
@@ -97,12 +101,12 @@ bytes. In the example the compression ratio is 2:1. It is evident
that the longer the program is, the better the compression ratio
is. The maximum compression ratio in a UNIX environment is 254:16
which equals approximately to 16:1. By using the method a one
megabyte of source code can be compressed to 64 kilobytes.
megabyte of source code file can be compressed to 64 kilobytes.
One might easily think that the program could be compressed to a
single byte by writing a one character long preprocessor directive
in the source file and defining the actual source code in the
command line, eg. 'cc hello.c -DX=main(){puts...'. With this
command line, eg. `cc hello.c -DX='main(){puts ...'`. With this
method nothing is gained, since the compiling commands must be
stored in a file, and that takes even more space than writing the
code in a source file as presented in listing 1.
@@ -111,12 +115,12 @@ code in a source file as presented in listing 1.
### Packing files in a UNIX environment
In a UNIX environment it is possible to write almost any program by
including the code in file names. Since '/' is used to separate
including the code in file names. Since `/` is used to separate
path components and cannot therefore exist in a file name, all
features of C-language cannot be used.
In C, the `/` is used as a division operator and it may also be a
part of a comment start and end identifier. This is, however, not a
part of a comment start and end identifier. This, however, is not a
dangerous limitation, since practice has shown that comments are
almost totally unnecessary. A real programmer can more easily
understand pure source code, and misleading comments are
@@ -127,7 +131,7 @@ when using integers.
Large programs must be separated into small modules. This enforces
people to write better programs, since monolithic programming style
cannot be used. Program development will also be faster, no extra
code need not be recompiled after changes have been made.
code needs be recompiled after changes have been made.
### Usage with currently available tools
@@ -136,30 +140,30 @@ I have tested how well this new method works with currently
available programming tools.
Any ANSI conforming C-compiler that runs under a REAL operating
system should be able to compile the code. (there may be problems
with some older UNIX variants)
system should be able to compile the code (there might be problems
with some older UNIX variants).
### Compilers:
### Compilers
These worked:
gcc versions 2.0, 2.1, 2.3.2 (ld failed at AIX with gcc 2.1)
cc (HP-UX)
cc (VAX)
- gcc versions 2.0, 2.1, 2.3.2 (ld failed at AIX with gcc 2.1)
- cc (HP-UX)
- cc (VAX)
These failed miserably:
cc (SunOs/Solaris) - could not start cpp properly
cc/xlc (AIX) - could not open source
- cc (SunOS/Solaris) - could not start cpp properly
- cc/xlc (AIX) - could not open source
### Other tools:
### Other tools
#### Debuggers: (tested at SunOs 4.1.2)
#### Debuggers: (tested at SunOS 4.1.2)
dbx - Quit with a very 'informative' error message:
"dbx: fatal error: Is a directory"
- dbx - Quit with a very 'informative' error message:
"dbx: fatal error: Is a directory"
gdb - Printed almost the same error message ":Is a directory".
- gdb - Printed almost the same error message ": Is a directory".
It was, however, possible to step through the code but
not list it.
@@ -170,7 +174,7 @@ None of the lints tested environments were able to parse the file.
### Conclusions
The method can be used to compress any types of files, actually the
The method can be used to compress any types of files and the
compression ratios are even better when compressing other files
than C-source. For example plain text files may be compressed with
INFINITE compression ratio. It is trivial task to compress a 100
+21 -17
View File
@@ -1,22 +1,26 @@
# Best One Liner
Mark Plummer
2901 Reckord Road
Fallston, MD, 21047
USA
Mark Plummer
2901 Reckord Road
Fallston, MD, 21047
US
## To build:
make all
```sh
make all
```
## To run:
./plummer number arg
```sh
./plummer number arg
```
where:
number is a number (try 21701)
arg is any argument
- number is a number (try 21701)
- arg is any argument
### INABIAF - it's not a bug it's a feature :-)
@@ -33,31 +37,31 @@ characters, and why?
This program prints out all numbers up to a given number of digits
on a single line. When the largest number is reached, the program
starts again with 0. It takes two arguments: the first argument
specifies the number to start counting from and uses leading 0's to
specifies the number to start counting from and uses leading `0`s to
indicate the number of digits, the second argument can be anything
but must be present.
Variable names are single characters chosen for their similarity to
other characters (O for 0, l for 1, S for 5 (in some fonts), and _
other characters (O for 0, l for 1, S for 5 in some fonts, and _
for ... well nothing really, but it is easy to miss). To prevent
the need for `strlen()`, the fact that argv is laid out sequentially
is exploited (ie. `argv[i + 1] == argv[i] + strlen(argv[i]) + 1`).
This is not portable (by the books), but it seems to work
everywhere I try (actually, for vms, that only holds for `i > 1`).
everywhere I try (actually, for VMS, that only holds for `i > 1`).
Also, I depend on the fact that a carriage return causes the line
just written to be overwritten. lint (and most compilers) complain
that there is no control path leading to a return from main(). At
just written to be overwritten. `lint` (and most compilers) complain
that there is no control path leading to a return from `main()`. At
125 characters, it still fits on a single line (for those of us who
don't mind ruining our eyes with 132 column screens).
The first statement points the base of `l` (the argument vector) to
be the first argument by incrementing it. It then assigns `O` to
point to the character before the first character of the second
argument which also happens to be the null termination of the first
argument which also happens to be the NULL termination of the first
argument. `*O` gets a `\r` assigned to it. Finally `0` is assigned to
the first character of the second argument which has the effect of
null terminating the first argument after the carriage return had
removed its null termination. I really tried to make the last part
NULL terminating the first argument after the carriage return had
removed its NULL termination. I really tried to make the last part
of that statement part of the original expression, but the best I
could do was attach it with a comma (against the advice of K&R).
The for loop runs the next for loop continuously (actually until
@@ -66,7 +70,7 @@ counting). The next for loop is the meat of the program. In the
initialization statement, the string pointed to by `l` (the first
argument containing the digits used for counting followed by a `\r`)
is printed, and `_` is started at the least significant digit in the
string. In the test portion, `_` is insured not to be past the
string. In the test portion, `_` is ensured not to be past the
beginning of the string (the most significant digit), and the digit
pointed to by `_` is incremented and checked to be sure that it _is_
greater than `9` (written here as `(S+*O+S)*S`). If the test fails,
Loaded 100 of 419 files, more files were not shown because too many files have changed in this diff. Show more