Add preview of 1984-2019

The 2020 winners are hinted it, but the source code is not there,
nor are the hints. Someone could look into the HTML and
see what was commented out, but that is not a problem because
WHO won is known and the name of their AWARD is known already.
Moreover a number of the winners have talked about what their
entirs do, so the commented out spoiler text is not a bit problem.

One will find HTML commented out with:

    <!-- XXX remove when 2020 is ready
    2020 links here
    XXX remove when 2020 is ready -->

The "XXX remove when 2020 is ready" string is found at the
start and end comment blocks.  Again, soneone could read
what was commented out, but that is OK since most of that
information is known or can be known.  The following files
have such HTML comment blocks in them.

    ./winners.html
    ./years-spoiler.html
    ./years.html

In addition, ./all/summary.txt was modified to not
include the 2020 entries for the momemt.

The 2020 winner code AND write-ups are NOT part of this set.

p.s. The all/all.tar.bz2 does not contain the 2020 source code (yet?).
This commit is contained in:
Landon Curt Noll committed 2020-12-30 16:57:03 -08:00
1 parent 28efc67f5d
commit c0663537cb
1683 files changed
+220064

No files matched your search

BIN
View File
Binary file not shown.
+90
View File
@@ -0,0 +1,90 @@
# %W% %G% %U%
#
# 1989 makefile
#
# Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
# All Rights Reserved. Permission for personal, educational or non-profit
# use is granted provided this this copyright and notice are included in its
# entirety and remains unaltered. All other uses must receive prior permission
# from Landon Curt Noll and Larry Bassel.
SHELL=/bin/sh
CFLAGS=-O
CC=cc
WINNERS=ovdluhe jar.1 jar.2 fubar westley paul robison roemer vanb tromp.bsd
ALTERNATE=jar.1.orig fubar.orig tromp.s5
all: ${WINNERS}
ovdluhe: ovdluhe.c
${CC} ${CFLAGS} $? -o $@
# NOTE: jar.1.c outputs its string in one section
# this program may not print well on some terminals
jar.1: jar.1.c jar.1.sh
rm -f jar.1
cp jar.1.sh jar.1
chmod +x jar.1
# NOTE: The jar.1.orig file is the original entry
jar.1.orig: jar.1.orig.c jar.1.orig.sh
rm -f jar.1.orig
cp jar.1.sh jar.1.orig
chmod +x jar.1.orig
jar.2: jar.2.c
${CC} ${CFLAGS} $? -o $@
# NOTE: fubar.c uses the /bin/sh shell
fubar: fubar.c fubar.sh
rm -f fubar
cp fubar.sh fubar
chmod +x fubar
# NOTE: The fubar.orig.c file is the original entry
fubar.orig: fubar.orig.c fubar.orig.sh
rm -f fubar.orig
cp fubar.orig.sh fubar.orig
chmod +x fubar.orig
westley: westley.c
${CC} ${CFLAGS} -Dtrgpune=putchar $? -o $@
paul: paul.c
${CC} ${CFLAGS} $? -o $@
robison: robison.c
${CC} ${CFLAGS} $? -o $@
roemer: roemer.c
${CC} ${CFLAGS} $? -o $@
# NOTE: this version requires BSD style signals and setitimer
# this may not work well on low baud rate terminals
# the file tromp.bsd.c is the original version
tromp: tromp.bsd.c
${CC} ${CFLAGS} $? -o $@
touch HI
-chmod 0666 HI
# NOTE: sites without BSD style signals and setitimer (e.g. System V.3)
# should use this version
tromp.s5: tromp.s5.c
${CC} ${CFLAGS} $? -o $@
touch HI
-chmod 0666 HI
vanb: vanb.c
${CC} ${CFLAGS} $? -o $@
clean:
rm -f ovdluhe.o jar.2.o fubar.o westley.o paul.o robison.o
rm -f roemer.o tromp.o vanb.o
rm -f x x1 ouroboros.c ouroboros.o fubar.orig.o tromp.bsd.o tromp.s5.o core
clobber: clean
rm -f ${WINNERS}
rm -f jar.1.o HI
rm -f ${ALTERNATE}
nuke: clobber
@true
install: all
cat ${WINNERS} > /dev/null
+32
View File
@@ -0,0 +1,32 @@
1989 marked the "The Sixth International Obfuscated C Code Contest"
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
Instructions for use: Run make to compile entries (it is possible
that on System V or non-unix systems the makefile needs to be
changed). Look at the source and try to figure out what the programs
do, and run them with various inputs. If you want to, look at the
hints files for (minor) spoilers.
This year, the Grand Prize was given to the most useful program.
The "Strangest abuse of the rules" award was given this year to stress
the fact that starting in 1990, compiling entries must result an
executable regular file.
In two other cases, we included System V portable versions of winning
programs. The makefile always uses the portable version of the "Best
self modifying program" because there as no loss of functionality in
using it. In the case of the "Best game" winner, however, some
functionality is lost in the portable version and so the makefile uses
the original program. System V users may need to change the makefile
to use the s5 version. See the hint files or the Makefile for details.
Rules and results were posted to comp.lang.c, comp.sources.unix, and
alt.sources. They have been made available on a wide number of Usenet
archive sites such as uunet. The 1989 winners will be published in the
Micro/Systems Journal.
+19
View File
@@ -0,0 +1,19 @@
#include <stdio.h>
#define QQ 1
#define TT 1
#define cc main(c,v) int c; char **v;{char tt[12],qq[7]; int q=0,o=1,l=1,m=1;struct {int c;} f;
#define ouroboros qq[6]='\0';tt[11]='\0';if(QQ==atoi(v[1])+1){(void)fprintf(stderr,"%s factorial = %d\n",v[1], TT);exit(1);}o=c+f
#define x ;while(EOF!=(o=getchar())){if(l && q=='Q' && o=='Q'){l=0;(void)getchar();(void)fread(qq,6,1,stdin);(void)printf("Q %6d",atoi(qq)+1);}else
if(m && q=='T' && o=='T'){m=0;(void)fread(tt,11,1,stdin);(void)printf("T %9d\n",atoi(tt)*QQ);}else {q=o;(void)putchar(o);}}exit(0);}
cc ouroboros.c -o x
#define zxc ;{/*
cat ouroboros.c | x $1 > x1
if [ $? -ne 0 ]; then
exit
fi
mv x1 ouroboros.c
chmod +x ouroboros.c
exec ouroboros.c $1
exit
*/
+60
View File
@@ -0,0 +1,60 @@
Best self-modifying program:
Jay Vosburgh
Sequent Computer Systems, Inc
15450 SW Koll Parkway
Beaverton, OR
97006
USA
Judges notes:
Run this with a single digit argument (or wait a long time).
There are 2 versions of this program, the one that was entered,
and one that was changed by the judges to be more portable. The
makefile runs the latter version by default.
The blank line at the beginning of the source is mandatory.
Do you know why?
The shell script run by the makefile joins lines that may be
cut up by mailers. The file "fubar.orig.c", for example, needs
the 6th and 7th lines joined together (with a space between
them) to recreate the original entry. If you fix the file, you
will need to change the last 8 linnes of "fubar.orig.sh" to read:
cp fubar.orig.c ouroboros.c
chmod +x ouroboros.c
csh ouroboros.c $1
rm -f ouroboros.c x1 x
The more portable version, "fubar.c", can be fixed by joining the
7th and 8th lines in the same way. As well, if you fix "fubar.c"
you will need to also change the last 8 lines to "fubar.sh" to read:
cp fubar.c ouroboros.c
chmod +x ouroboros.c
csh ouroboros.c $1
rm -f ouroboros.c x1 x
Selected notes from the author:
In a nutshell, this is probably the slowest and most
obnoxious factorial program ever written. Unfortunately,
the name of the C source must be "ouroboros.c"; the name is
hard-coded into the program.
The source is a legal shell script and a legal C program.
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"
much more so.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+18
View File
@@ -0,0 +1,18 @@
#include <stdio.h>
#define QQ 1
#define TT 1
#define cc main(c,v) int c; char **v;{char tt[12],qq[7]; int q=0,o=1,l=1,m=1;struct {int c;} f;
#define incest qq[6]='\0';tt[11]='\0';if(QQ==atoi(v[1])+1){(void)fprintf(stderr,"%s factorial = %d\n",v[1], TT);exit(1);}o=c+f
#define x ;while(EOF!=(o=getchar())){if(l && q=='Q' && o=='Q'){l=0;(void)getchar();(void)fread(qq,6,1,stdin);(void)printf("Q %6d",atoi(qq)+1);}else
if(m && q=='T' && o=='T'){m=0;(void)fread(tt,11,1,stdin);(void)printf("T %9d\n",atoi(tt)*QQ);}else {q=o;(void)putchar(o);}}exit(0);}
cc incest.c -o x
#define zxc ;{/*
cat incest.c | x $1 >! x1
if ($status != 0) then
exit
endif
mv x1 incest.c
chmod +x incest.c
exec incest.c $1
exit
*/
+19
View File
@@ -0,0 +1,19 @@
:
# to run fubar in the 'proper' way
# parse args
if [ $# -ne 1 ]; then
echo "usage: $0 number" 1>&2
exit 1
fi
# run/compile it
rm -f ouroboros.c x1 x
ex - <<EOF
r fubar.c
7,8j
w ouroboros.c
EOF
chmod +x ouroboros.c
ouroboros.c $1
rm -f ouroboros.c x1 x
+1
View File
@@ -0,0 +1 @@
char*_="Hello world.\n";
+40
View File
@@ -0,0 +1,40 @@
Strangest abuse of the rules:
Jari Arkko
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
Judges notes:
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
On systems that have symbolic links, we suggest:
ln -s /dev/tty jar.1.o
cc -c jar.1.c
if your system has symbolic links. The shell script run
by the makefile simply cats the .o file to the terminal
which can be used as a last resort.
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:
This program is (supposedly) the smallest C program able to
print "Hello world.". The compilation itself produces the
desired printout and the program need not be actually run.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+1
View File
@@ -0,0 +1 @@
char*He="llo world.\n";
+8
View File
@@ -0,0 +1,8 @@
:
# 'run' jar.1.orig
# run/compile it
rm -f jar.1.orig.o
cc jar.1.orig.c -c
cat jar.1.orig.o
rm -f jar.1.orig.o
+8
View File
@@ -0,0 +1,8 @@
:
# 'run' jar.1
# run/compile it
rm -f jar.1.o
cc jar.1.c -c
cat jar.1.o
rm -f jar.1.o
+44
View File
@@ -0,0 +1,44 @@
#define d define
#d a include
#a <stdio.h>
#a <string.h>
#a <ctype.h>
#d p char*
#d P ,(p)
#d T(E) !strcmp(E,"()")
#d U return
#d W while
#d X sbrk(199)
#d z atof
#d e isspace
#d D A(_)
#d E S(C(_))
#d B(y) p y(_)p _;{
#d G(y,V) B(y)p i;U sprintf(i=X,"%lf",z(E)V z(S(C(D)))),i;}
p sbrk(),*S(),*j(),*O,*H;K,Y,M=14;double
z();Q(_)p _;{int V=0;W(e(*_))_++;H=_;W(V|!(e
(*H)|*H==')'||(*H=='('&&H-_)))V+=(*H=='(')-(*H==
')'),H++;U H-_;}B(C)U _++,Y=Q(_),_=strncpy(X,_,Y),_[
Y]=0,_;}B(A)_++,_+=Q(_);W(e(*_))_++;U O=X,*O='(',strcpy(
O+1,_),O;}B(Z)U _;}B(c)U C(E);}B(q)U A(E);}B(t)p i=E;U H=S(C
(D)),sprintf(O=X,T(H )?"(%s)":"(%s %s",i,H+1)
,O;}B(F)U S(C(A(T(E)?D:_)));}L(i,s)p
i,*s;{U isdigit(*i) ? z(i)!=z(s):strcmp(i,s);}
B(b)U L(E,S(C(D)))?"()":"t";}B(R)U E;}B(o)U z(E)<z(S(C(D)))?
"t":"()";}G(f,+)G(g,-)G(h,*)p r[4][2]={"function" P R,
"quote"P C,"lambda"P Z,"defun"P j};B(j)U r[M][1]=D,*
r[M++]=C(_);}p not[99][2]={"if"P F,"equal"P b,"<"
P o,"+"P f,"-"P g,"*"P h,"car"P c,"cdr"P q,
"cons"P t,"t","t"};B(S)int Li,s;p u;if(
isdigit(*_)|T(_))U _;for(Y=M;Y--;)
if(!strcmp(_,*r[Y]))U r[Y][1]
;u=E,_=D;if(*u-'(')U(*((p(*)())u)
)(_);s=Li=M;W(!T(_))r[M][1]=E,*r[M++]
="",_=D;O=C(u);W(!T(O))*r[Li++]=C(O),O=A(O);U O=S
(C(A(u))),M=s,O;}main(){H=O=X,Y=0;W(Y|!e(K=getchar()))K==
EOF?exit(0):0,Y+=(K=='(')-(K==')'),*H++=K;*H=0,puts(S(O))
,
main();{printf("XLISP 4.0\n");}}
+71
View File
@@ -0,0 +1,71 @@
Best of show:
Jari Arkko, Ora Lassila, Esko Nuutila
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
Judges notes:
This is the most useful program entered this year. It is a
rather large subset of lisp. It has no error recovery, and
performs rather poorly in a number of cases. Even so, placing
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:
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
Below are sample lisp expressions you might choose to try as input.
The program implements a conventional lisp listener, i.e. you type in
lisp expressions (followed by CR), the program evaluates them and
prints out the return values. End execution by typing an end-of-file
character.
(+ 2.5 3.1)
(defun fib (n)
(if (< n 2)
1
(+ (fib (- n 2)) (fib (- n 1)))))
(fib 10)
(defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
(! 7)
(defun fn1 (fn) (+ (fn 1 2) (fn 3 4)))
(defun fn2 (a b) (+ a b))
(fn1 (function +))
(fn1 (function fn2))
(fn1 (function (lambda (z1 z2) (+ z1 z2))))
(quote a)
(cons (quote (a b)) (quote (c d e)))
(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
you type your input, or any other unnecessary whitespace. Please try to
avoid any undefined variables or functions, wrong number of arguments
etc. All these errors are likely to dump core (i.e. there are no error
checks in the program).
Traditional Lisp implementations use cons cells as the main data
structure. Lists are organized of pointer chains of these cells.
In this program, an alternate representation was chosen: char*'s.
All list operations, including the ones in the interpreter, are
made using string representations of the lists. These operations
must count parentheses and skip whitespace. This leads to extremely
poor performance!
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+21
View File
@@ -0,0 +1,21 @@
#include <string.h>
typedef char ape
#define D define
#D EA register
#D EP unsigned
#D A 1
#D AP (A<<A)
#D P (A<<AP)
#D AE ((P<<P)<<A)
#D PE (((A<<P)<<P)<<P)
#D E ((EP)A>>A)
#D APE {EA EP ape ea=AE;while(ea--) e[ea]=E;}
;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);}
+45
View File
@@ -0,0 +1,45 @@
Most humorous output:
Oskar von der Luehe
Institut fuer Astronomie
ETH - Zentrum
8092 Zuerich
Switzerland
Judges notes:
Run this program using your favorite text file as input. Files
such as mailboxes, man pages and usenet articles are especially
recommended. You will get different output each time you run it.
Run the program this way:
ovdluhe < textfile
The program stops when it reaches the end of the template buffer
by chance or is killed.
Selected notes from the author:
This program implements an "Eddington ape" - it generates
random text from a supplied template. The template text file
is read through stdin. The larger the template, the better the
result. A maximum of 2**12 chars are used. From the template,
the program calculates the statistics of chars that immediately
follow a given string (correlator string) of a certain length
(currently 4 - can be varied by changing the definition for P
accordingly). A character is randomly chosen, weighted by its
probability to occur after the correlator string. That
character is printed to stdout and placed at the end of the
correlator string, whose first character is discarded.
Meaningful words are therefore usually preserved, the effect on
sentences can be dramatically random.
You might want to vary the definition of P between 2 and 10 and
observe the result.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+35
View File
@@ -0,0 +1,35 @@
#include <stdio.h>
#define f int
#define v (void)printf(
#define x ),exit(1);
#define y ){if(n)c=z(n,u),u=n,n=c;o[i]=n?'0'+(1&*n):'0';}
#define z(a,b) (f*)(~1&*a^(f)b)
#define k(l) if(!(l=(f*)malloc(sizeof(l))))v 23+m x if(1&(f)l)v 39+m x*l=
r(p,q,d)f*p,*q;{char o[81];f*n=p,i=39,*c,*u=d?q:z(p,q);o[40]='0'+(1&*p);
for(;i>=0;i--y u=d?z(p,q):q;n=p;for(i=41;i<79;i++y o[i++]='\r';o[i++]=0;
v o);(void)fflush(stdout);sleep(1);}
main(a,c)char**c;{char*u,*malloc(),*m=
"Usage: black [string]\n\0No more memory\n\0Unusable memory alignment\n\0jt,s@m@ (beleY%XX&Yz {z&z}i|R(|)*((.)i)hiniFiGJ%FG.JJgJ: ;;&;z {z&z}-RS/ROiOV OP+PsaPh+ijainnjmamfmfAlnnnnphppopv%vvgv.aABiB1/BVP11/1.%..&.OhrR-WV V1#1VP1CcC0R\
\n\n'CVP0\n!\n\n'\nEaEEnEamat!akckk'kwaww'wz,zzozEit +",
*n=m;f*q,*p=0,*g,b=3,d;
if(a>2)v m x n=a>1?c[1]:n;
/*v"\t\t\t\t\tV\n");*/
k(q)0;u=n;a=~1&'j';
while(a!='x'){
/*r(q,p,b);*/
for(;;u+=3){
u= *u?u:n;
if((~1&*u)==a&&(1&*q)<<1==(2&u[2]))break;
}
a=~1&u[1];
d=(8&u[2])>>3;
if(16&u[2])putchar(u[3]);
if(4&u[2])*q|=1;else*q&=~1;
if(b==d)g=p;else{
g=z(q,p);
if(!g){k(g)(f)q;*q^=(f)g;}
}
p=q;q=g;b=1-d;
}
/*r(q,p,b);v"\n");*/exit(0);
}
+109
View File
@@ -0,0 +1,109 @@
Most complex algorithm:
Paul E. Black
CIRRUS LOGIC, Inc.
1463 Centre Pointe Dr.
Milpitas, CA
95035
USA
Judges notes:
The original source contained a long line which caused many
mailers to barf. The original file may be re-constructed by
removeing the trailing "\" on line 12 and joining lines 12 and
13 together without a space.
WHAT FOLLOWS IS A DETAILED PROGRAM EXPLINATION 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:
This programs computes and prints Fibonacci numbers by
simulating a Turing machine with the proper program.
Understanding the C program, i.e., a Turing machine simulator,
is only the first and simplest step. The Turing machine
program must be understood, too! (it is trivial, perhaps even
natural to write incredibly obscure Turing programs.)
If the program is invoked with an operand, the operand is used
as the Turing program. It includes a "trace" facility,
subroutine r (commented out for obscurity), to help write and
debug Turing programs. Just the thing for some fun in a Theory
of Computation class.
The Turing machine tape is represented as a doubly linked list
of pointers. The forward and backward links are XOR'd together
and stored in one pointer. If we always keep one of the links
on hand, we can recover the other link at any time. The
variable q is the scan head (and a pointer at some tape cell),
and p is a "previous" link. The state of the tape is stored in
the low order bit of the pointer. Since we always allocate an
even number of bytes, the low order bit carries no information
(see portability below.) Memory representing a tape cell is
allocated when the cell is first scanned. Thus the simulation
begins with a tape effectively the size of virtual memory set
to all zeros. Since a header can be added to any Turing
program to write initial data and position the scan head, this
is little loss of generality.
The simulated Turing machine has a single tape with either an 1
or a 0 in each cell. The Turing machine language format is a
string of three bytes. The first byte is the current state.
The second byte is the next state. (The last bit of states is
ignored, e.g., B and C are the same state, in an attempt to be
able to have interesting words in the program.) The third byte
is composed of bits. Bit 1 (2&byte) is the symbol scanned,
i.e. an instruction is selected for state and for a match with
the symbol under the scan head. Bit 2 (4&byte) is the new
symbol to be written to the cell. Bit 3 (8&byte) is the
direction to move the scan head: 0 for left and 1 for right.
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
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
search begins again at the first of the string. Thus states
can be used as local labels in different places.] 3) change to
the next state, 4) print a character if indicated, 5) write the
tape symbol, and 6) move the scan head. The cycle then repeats
with step 1. A call to the trace routine is just before step
2, but is commented out.
The following ROT13'ed text is a quick outline of the actual
Turing program:
Urer vf n dhvpx bhgyvar bs gur Ghevat cebtenz: gur
cerivbhf naq pheerag Svobanppv ahzoref ner xrcg va onfr
1 sbez jvgu gur pheerag ba gur evtug. Gur svefg guerr
fgrcf frg hc gur svefg gjb ahzoref, 1 naq 1. Gura
[ortvaavat jvgu "@ ("] n znexre bs VVV vf perngrq naq
gur pheerag ahzore vf pbcvrq gb gur evtug bs gur
znexre. Gura [ortvaavat jvgu "BI "] gur ahzore vf
pbairegrq gb ovanel ol ercrngrq qvivqvat ol 2 yrnivat V
sbe erznvaqre 1, naq VV sbe erznvaqre 0. Arkg
[ortvaavat jvgu "JI "] gur ovanel ercerfragngvba vf
cevagrq naq vgf flzobyf naq gur znexre ner renfrq.
Svanyyl [ortvaavat jvgu "RRa"] gur gjb ahzoref ner
nqqrq naq gur pheerag ahzore pbcvrq gb gur yrsg gb
orpbzr gur cerivbhf. Gura gur plpyr ercrngf.
The program requires that the lowest bit of a pointer to be 0.
I could have squeezed the program under 1024 bytes without the
trace subroutine, but I felt it was important for understanding
the program. Besides it is fun to watch the tape zooming back
and forth as the program runs. A much better debugger or trace
could easily be added.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+33
View File
@@ -0,0 +1,33 @@
typedef struct A*B,*(*C)();struct A{C(*d)();B e;}*v(),*b;C n[256];
# include <stdio.h>
#define a (d->e)
#define o (B)printf
#define X(_){return _;}
#define Y(_,A)B _(d,e)B d,e;X(A)
#define Z(P)C P(f,g,h,i)C f,g,h,i;X(P)
#define c(_)(b=(B)malloc(sizeof(*b)),b->d=_,b->e=d,b)
#define _(D,E,F,G,H)B D();Y(D/**/f,E)Y(D/**/g,F)Y(D/**/h,G)Y(D/**/i,H)Y(D,(*(*d->d)(D/**/f,D/**/g,D/**/h,D/**/i))(d,e))
Z(f)
Z(g)
Z(h)
Z(i)
_(j,d,d,j a,j a)
_(k,d,c(h),c(h),c(h))
_(l,c(i),d,c(i),c(i))
_(m,c(g),c(f),l(m a),k(m a))
_(p,d,l(m(d)),k(p a),l(m a))
_(q,l(p(d)),m(d),l a,k(q a))
_(r,m(d),k(mf a),l(r a),k a)
_(s,d,e,o("0",s a),o("1",s a))
_(t,d,p(e),k(t(a,e)),v(k(t(a,e)),e))
_(u,k(e),l(r(e)),k(v(a,e)),l(v(a,e)))
_(v,e,r(e),u(e,a),u(q(e),a))
_(w,o("0"),d,s(d),s(d))
_(x,(*n[getchar()])(d),o("-1"),w(p(d,o("-"))),xh(d))
_(y,xf(mg()),v(d,p(yf())),v(d,yf()),t(d,yf()))
_(z,xf(yf()),(*(*j(d)->d)(w,x))(d),xf(k(d)),xf(l(d)))
main(){
n['(']=zf;n['x']=yi;n['-']=yg;
n['+']=yh;n['0']=zh;n['1']=zi;
n[' ']=xf;n[')']=n['\n']=kf;
o("\n",zg(yf()));}
+51
View File
@@ -0,0 +1,51 @@
Best minimal use of C:
Arch D. Robison
University of Illinois
1304 W. Springfield Ave.
Urbana, IL
61801
USA
Judges notes:
Sites with punch card facilities will be happy to note that
the source deck can be re-collated with an ASCII sort.
Note that this program uses only a small subset of the
constructs that the C language supports.
Selected notes from the author:
This program is a handy picoAPL interpreter written in C--. It
outputs the evaluation of an APL expression from standard
input. Functions are limited to dyadic +,-,x, and unary -;
numerals must be binary. Parentheses may be used for
grouping. For example:
101x111-100
prints:
1111
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
and confusing features: arithmetic, logical operations, shifts,
relationals, address-of, and flow control. In fact, the only
expressions retained are function calls, indirection, array
assignments, the ',' operator, and sizeof. Despite these
restrictions, the C-- program does arithmetic on arbitrarily
large binary numbers.
To obtain a C-- reference, simply rip out the irrelevant pages
from your K&R C manual. To obtain a C-- compiler, simply rip
out the irrelevant bytes from your cc compiler.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+36
View File
@@ -0,0 +1,36 @@
char
_3141592654[3141
],__3141[3141];_314159[31415],_3141[31415];main(){register char*
_3_141,*_3_1415, *_3__1415; register int _314,_31415,__31415,*_31,
_3_14159,__3_1415;*_3141592654=__31415=2,_3141592654[0][_3141592654
-1]=1[__3141]=5;__3_1415=1;do{_3_14159=_314=0,__31415++;for( _31415
=0;_31415<(3,14-4)*__31415;_31415++)_31415[_3141]=_314159[_31415]= -
1;_3141[*_314159=_3_14159]=_314;_3_141=_3141592654+__3_1415;_3_1415=
__3_1415 +__3141;for (_31415 = 3141-
__3_1415 ; _31415;_31415--
,_3_141 ++, _3_1415++){_314
+=_314<<2 ; _314<<=1;_314+=
*_3_1415;_31 =_314159+_314;
if(!(*_31+1) )* _31 =_314 /
__31415,_314 [_3141]=_314 %
__31415 ;* ( _3__1415=_3_141
)+= *_3_1415 = *_31;while(*
_3__1415 >= 31415/3141 ) *
_3__1415+= - 10,(*--_3__1415
)++;_314=_314 [_3141]; if ( !
_3_14159 && * _3_1415)_3_14159
=1,__3_1415 = 3141-_31415;}if(
_314+(__31415 >>1)>=__31415 )
while ( ++ * _3_141==3141/314
)*_3_141--=0 ;}while(_3_14159
) ; { char * __3_14= "3.1415";
write((3,1), (--*__3_14,__3_14
),(_3_14159 ++,++_3_14159))+
3.1415926; } for ( _31415 = 1;
_31415<3141- 1;_31415++)write(
31415% 314-( 3,14),_3141592654[
_31415 ] + "0123456789","314"
[ 3]+1)-_314; puts((*_3141592654=0
,_3141592654)) ;_314= *"3.141592";}
+29
View File
@@ -0,0 +1,29 @@
Best layout:
Lievaart, Roemer B.
VU-Informatica, Amsterdam
Marcusstraat 29/2,
NL 1091 TJ Amsterdam
Netherlands
Judges notes:
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:
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.)
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+211
View File
@@ -0,0 +1,211 @@
Subject: 6th International Obfuscated C Code Contest Rules
Newsgroups: comp.lang.c,comp.unix.wizards
Keywords: rules,1989,obfuscate,contest,IOCCC
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
Obfuscate: tr.v. -cated, -cating, -cates. 1. a. To render obscure.
b. To darken. 2. To confuse: Their emotions obfuscated their
judgement. [LLat. obfuscare, to darken : ob(intensive) +
Lat. fuscare, to darken < fuscus, dark.] -obfuscation n.
obfuscatory adj.
GOALS OF THE CONTEST:
* To write the most Obscure/Obfuscated C program under the rules below.
* To show what should NOT be done in C programs.
* To provide a safe forum for poor C code. :-)
RULES:
To help us handle the vast volume of entries, we ask that you
follow the rules below. Sorry for the length, but we need all
the help we can get!
1) Your source MUST be 1536 bytes or less, and it must be a complete
program, not just a subroutine.
2) To help us process your entries, we ask that you submit entries
in the following format. Please be sure to include the --- lines,
otherwise our extraction program may skip your entry!
---header items---
name: Your name, of course!
org: School/Company/Organization
email address: Email address from a well known site, or in a registered domain
postal address: Postal address
include your country as well
environment: Indicate the Hardware
and OS under which your program was tested
entry: 5 <number of entries sent so far including this one>
remarks: <see below>
---how to compile---
X Give the command(s) needed to compile your program.
X Follow the same rules as given for the program below except that the
X command size must be 160 characters or less.
---program---
X Place obfuscated source of 1536 characters or less in this section.
X Add a leading X to each line to avoid problems with mailers.
X Some mailers don't like files with very long lines. If your entry contains E
C lines longer 80 chars we ask you to form continuation line sets. To form E
C a continuation line set, place an 'E' character at the point of a split E
C and place a C (instead of an X) at the beginning of the next line. E
C Finally, end the continuation line set as normal.
X The E\nC's and leading X's will be removed prior to extraction and thus E
C they don't contribute toward the source character count. All other E
C characters are considered to be source. Whitespace after 'X' or 'C' E
C and before the 'E' is significant, we added it here for readability.
X Newlines and tabs each count as 1 character. Assume 8 character tab stops.
X If your entry does not end in a newline, leave a final 'E' on the end. E
---end---
3) Regarding the header items:
* Any text outside of the above format will be kept confidential.
* All header lines are required, but you may use 'anonymous'
for any header line other than 'remarks' or 'entry'.
* In the 'remarks' please include:
- what this program does
- why you think the program is obfuscated
- any other remarks you wish to make
4) Your entry should be written in common C. (K&R + common extensions)
Due to the lack of ANSI C compilers, it is suggested, but not
required, that you avoid use of constructs unique to ANSI C.
5) The program must be of original work. All programs must be
in the public domain. All copyrighted programs will be rejected.
6) Entries must be received between 26-Mar-89 0:00 GMT and
26-May-89 0:00 GMT. Email your entries to:
...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!obfuscate
We will attempt to Email a confirmation of receipt of contest
entries, however since Email is not reliable you may not receive it.
We regret that we can no longer accept entries via postal mail.
7) Each person may submit up to 8 entries. Multiple entries must
be sent in separate Email letters.
8) Entries that can not be built automatically in a portable makefile
are not allowed. (e.g., don't use #include "/dev/tty")
ANNOUNCEMENT OF WINNERS:
* First announcement will be at the Summer 89 Usenix BOF.
* Winning entries will be posted in mid June 1989 to
comp.sources.unix as well as news groups where these rules
were posted. (depending on the judges work load)
* Winning entries will be deposited into the uunet archives.
* An article containing the winning entries will be published
in a future issue of the "Micro/Systems Journal".
* Winners receive international fame and flames! :-)
JUDGING:
Awards will be given to the best entry in a number of categories.
The actual category list will vary depending on the types of entries
we receive. As a guide, consider using the following:
* The best small one line program
* The most obscure algorithm
* The strangest source layout
* The most useful obfuscated program
* The most creatively obfuscated program
* Best obfuscated entry smaller than 256 bytes
* Best obfuscated entry smaller than 1024 bytes
* <anything else so strange that it deserves an award>
POINTS TO PONDER:
People are encouraged to examine winners of the previous
contests. A copy of these entries was posted to
comp.sources.unix. Contact the comp.sources.unix moderator, or
some archive site (such as uunet). Keep in mind that rules
change from year to year, so some winning entries may not be
valid entries this year. What was unique and novel one year
might be 'old' the next year. In short, use your best judgement.
We examine each entry on several levels of confusion. For example
each entry is judged when we:
* look at the original source
* run it through: sed -e ',^#[ ]*define,d' | /lib/cpp
* run it through a C beautifier
* examine the algorithm
* compile and lint it
* execute it
One line programs are best when they are short, obscure and concise.
We tend to dislike programs that:
* are very hardware specific
* are very OS or Un*x version specific
(index/strchr differences are ok, but
socket/streams specific code is likely not to be)
* dump core or have compiler warnings
(it is ok only if you warn us in the 'remark' header item)
* won't compile under both BSD or SYS V Un*x
* use an excessively long compile line to get around the
size limit
* are longer than they need to be
* are similar to previous winners
* are similar to previous losers :-)
Simply abusing #defines or -Dfoo=bar won't go as far as a program
that is more well rounded in confusion.
Unless you are cramped for space, or unless you are entering the
'best one liner' category, we suggest that you format your program
in a more creative way than simply forming excessively long lines.
We like programs that:
* are as concise and small as they need to be
* do something quasi-interesting
* pass lint without complaint
* are portable
* are unique or novel in their obfuscation style
* use a number of different types of obfuscation
* make us laugh and/or throw up :-)
Some types of programs can't excel in some areas. We try to account
for this by giving awards to programs in a number of areas. Of course,
your program doesn't have to excel in all areas, but doing well in
several helps.
Be creative!
The Judging will be done by Landon Noll and Larry Bassel. If you have
any QUESTIONS or COMMENTS, please feel free to send them to:
...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!judges
judges@toad.com
however contest entries should be sent to:
...!{sun,pacbell,uunet,pyramid,amdahl}!hoptoad!obfuscate
obfuscate@toad.com
chongo <Landon Curt Noll> /\cc/\ hoptoad!chongo
Larry Bassel {amdahl,ucbvax,cbosgd}|sun!lab
p.s. The 1989 contest is being dedicated to the |\_.^
brain that was removed from Bill the Cat. (@ o)
*Ackpt!* {:}
U
+19
View File
@@ -0,0 +1,19 @@
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,
1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-11,-12,
12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i])-Q[i]
){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);printf(
"\033[%dm "+(K-k?0:5),k);K=k;}Q[263]=c=getchar();}G(b){for(i=4;i--;)if(q[i?b+
n[i]:b])return 0;return 1;}g(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char*
*V,*a;{h[3]=1000000/(l=C>1?atoi(V[1]):2);for(a=C>2?V[2]:"jkl pq";i;i--)*n++=i<
25||i%12<2?7:0;srand(getpid());system("stty cbreak -echo stop u");sigvec(14,v,
0);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<0){if(G(x+
12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(j%12==10){
for(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G(x=17)||(c
=a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if(c==a[2])G
(++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){s=sigblock(
8192);printf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]=
0);while(getchar()-a[4]);puts("\033[H\033[J\033[7m");sigsetmask(s);}}d=popen(
"stty -cbreak echo stop \023;cat - HI|sort -rn|head -20>/tmp/$$;mv /tmp/$$ HI\
;cat HI","w");fprintf(d,"%4d on level %1d by %s\n",w,l,getlogin());pclose(d);}
+115
View File
@@ -0,0 +1,115 @@
Best game:
John Tromp
Centre for Mathematics and Computer Science (CWI)
Oetgensstraat 7
1701CK Heerhugowaard
Netherlands
Judges notes:
This is a character terminal version of the TETRIS program.
It runs on a VT100 compatible terminal or emulator. It is
best used at 4800 baud or more.
Usage:
tromp [drops_per_sec [cmd_string]]
tromp.s5 [1 [cmd_string]]
By default, "drops_per_sec", the number of times an object
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
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
character again, which by default is "p".
This original program requires a BSD-style interval timer and
and new BSD signal interface. If you are using System V.3
or earlier, for example, you will need to make "tromp.s5"
instead of "tromp". You can change the default make rule
by changing "tromp" to "tromp.s5" in the "WINNERS=..." line
of the Makefile.
The "tromp.s5" version is not as functional as "tromp".
The "drops_per_sec" is ignored and defaults to 1. The level
is always reported as 0.
As was stated last year, we are likely to be more strict about
portability in the future. [ We mean it this time :-) ]
Selected notes from the author:
This program plays the familiar game of `TETRIS' with the
following features:
* outputs vt100-like escape-sequences for cursor
positioning and normal/reverse video in curses
like fashion (minimal output for screen updates)
* continuously increasing speed (except in pause)
* start speed selectable by giving n as first argument,
where n is the number of drops per second (default=2).
* controls also selectable by giving as the second argument
a string of 6 characters. By default they are "jkl pq".
* screen is blanked during the pause and the score is shown
* maintains a high-score table
Giving a full path name for the table will result in a
system-wide hiscore allowing a competition between users.
The author provided us with the following notes and new version of
the program:
Here is a somewhat improved version of my tetris entry. All the
changes are in the popen() at the end. Formerly a move was done
to the HI score file which is not permitted for other users. Now
other users can change the HI score file. The extra option -m is
passed to sort, so that it knows that its input files are already
sorted. The -o output option of sort is used instead of a
temporary file.
You may also want to consider giving just the raw option to stty
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.
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,
1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-11,-12,
12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i])-Q[i]
){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);printf(
"\033[%dm "+(K-k?0:5),k);K=k;}Q[263]=c=getchar();}G(b){for(i=4;i--;)if(q[i?b+
n[i]:b])return 0;return 1;}g(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char*
*V,*a;{h[3]=1000000/(l=C>1?atoi(V[1]):2);for(a=C>2?V[2]:"jkl pq";i;i--)*n++=i<
25||i%12<2?7:0;srand(getpid());system("stty cbreak -echo stop u");sigvec(14,v,
0);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<0){if(G(x+
12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(j%12==10){
for(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G(x=17)||(c
=a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if(c==a[2])G
(++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){s=sigblock(
8192);printf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]=
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 (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+19
View File
@@ -0,0 +1,19 @@
long h[4];E[80],S;t(){signal(14,t);if(S)longjmp(E,1);}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,1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-
11,-12,12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i
])-Q[i]){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);
printf("\033[%dm "+(K-k?0:5),k);K=k;}alarm(1);Q[263]=c=((S=1)&&!setjmp(E))?
getchar():-1;alarm(0);}G(b){for(i=4;i--;)if(q[i?b+n[i]:b])return 0;return 1;}g
(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char**V,*a;{for(a=C>2?V[2]:
"jkl pq";i;i--)*n++=i<25||i%12<2?7:0;srand(getpid());system("stty raw -echo");
signal(14,t);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<
0){if(G(x+12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(
j%12==10){for(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G
(x=17)||(c=a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if
(c==a[2])G(++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){
printf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]=0);
while(getchar()-a[4]);puts("\033[H\033[J\033[7m");}}system("stty cooked echo")
;d=popen("cat - HI|sort -rn|sed -n 1,20p>/tmp/$$;mv /tmp/$$ HI;cat HI","w");
fprintf(d,"%4d on level %1d by %s\n",w,l,getlogin());pclose(d);}
+1
View File
@@ -0,0 +1 @@
main(Q,O)char**O;{if(--Q){main(Q,O);O[Q][0]^=0X80;for(O[0][0]=0;O[++O[0][0]]!=0;)if(O[O[0][0]][0]>0)puts(O[O[0][0]]);puts("----------");main(Q,O);}}
+40
View File
@@ -0,0 +1,40 @@
Best one liner:
David Van Brackle
Department of Computer Science
University of Central Florida
Orlando, Florida
32816
USA
Judges notes:
This program computes all proper subsets of the set of
arguments passed to it. Each subset is printed with one
element on each line, followed by a line of ten dashes.
Try:
vanb the rug gary lent
vanb unix is better than os/2
Selected notes from the author:
The program has the following charming and possibly
non-portable features:
* It has no local or global variables,
only the command-line parameters.
* It calls main recursively.
* It alters the command-line parameters.
* It uses the fact that if the high bit is set in a character
variable, the value is negative.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.
+24
View File
@@ -0,0 +1,24 @@
/**//*/};)/**/main(/*//**/tang ,gnat/**//*/,ABBA~,0-0(avnz;)0-0,tang,raeN
,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN){(!tang&&
noon!=-1&&(gnat&2)&&((raeN&&( getchar(noon+0)))||(1-raeN&&(trgpune(noon
)))))||tang&&znva(/*//**/tang ,tang,tang/**|**//*/((||)))0(enupgrt=raeN
(&&tang!(||)))0(rahcteg=raeN( &&1==tang((&&1-^)gnat=raeN(;;;)tang,gnat
,ABBA,0(avnz;)gnat:46+]552&)191+gnat([kri?0>]652%)191+gnat([kri=gnat
(&&)1-^gnat(&&)1& ABBA(!;)raeN,tang,gnat,ABBA(avnz&&0>ABBA{)raeN
,/**/);}znva(/*//**/tang,gnat,ABBA/**//*/(niam;}1-,78-,611-,321
-,321-,001-,64-,43-,801-,001-,301-,321-,511-,53-,54,44,34,24
,14,04,93,83,73,63,53,43,33,85,75,65,55,45,35,25,15,05,94,84
,74,64,0,0,0,0,0,0,/**/){ABBA='N'==65;(ABBA&&(gnat=trgpune
(0)))||(!ABBA&&(gnat=getchar(0-0)));(--tang&1)&&(gnat='n'<=
gnat&&gnat<='z'||'a'<=gnat&&gnat<='m'||'N'<=gnat&&gnat<='Z'
||'A'<=gnat&&gnat<='M'?(((gnat&/*//**/31/**//*/,21,11,01,9,8
,7,6,5,4,3,2,1,62,52,42,/**/)+12)%26)+(gnat&/*//**/32/**//*/,
22,12,02,91,81,71,61,51,41{=]652[kri};)/*pry*/)+65:gnat);main
(/*//**\**/tang^tang/**//*/,/* */,~/*//*-*/tang,gnat,ABBA-
0/**//*/(niam&&ABBA||))))tang( rahcteg&&1-1=<enrA(||))tang(
enupgrt&&1==enrA((&&)2&gnat(&& )1-^tang(&&ABBA!(;)85- =tang
(&&)'a\'=gnat(&&)1-==gnat(&&)4 ==ABBA(&&tang!;))))0(enupgrt=
gnat(&&)tang!((||)))0(rahcteg =gnat(&&tang((&&ABBA;;)1-'A'=!
'Z'=tang(&&ABBA{)enrA/***/);gnat ^-1&&znva(tang+1,gnat,1+gnat);
main(ABBA&2/*//*\\**/,tang,gnat ,ABBA/**//*/(avnz/**/);}/*//**/
+126
View File
@@ -0,0 +1,126 @@
Most algorithms in one program:
Merlyn LeRoy (Brian Westley)
Starfire Consulting
1026 Blair Ave.
St. Paul, MN
55104
USA
Judges notes:
There is a secret way to get ONE of the versions to print out
"Hello, world!\n". Can you find how to do it?
Try the following commands:
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.
Selected notes from the author:
This is a filter. If it is run with no arguments, it copies
stdin to stdout. With one argument, it ROT13's stdin to
stdout. With two arguments, it reverses stdin to stdout. With
three arguments, it does both. It requires the ASCII character
set, with all characters being in 0..255, and EOF must be -1.
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
(ROT13 and reversed)).
When compiling these versions, one needs to define 'trgpune'
in the compile line. Example:
cc -Dtrgpune=putchar ver3.c -o ver3
"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
function; otherwise I would have an unidentifed 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 supercede 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
"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
(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).
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
first argument (argc) must be at least one).
I can't use any flow control. If I used if(), I would have a
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);
which is the same as:
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);
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!
Normally (!), a reversible C program is done thus:
/**/ 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/**/
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
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
will lack a terminating newline.
Copyright (c) 1989, Landon Curt Noll & Larry Bassel.
All Rights Reserved. Permission for personal, educational or non-profit use is
granted provided this this copyright and notice are included in its entirety
and remains unaltered. All other uses must receive prior permission in writing
from both Landon Curt Noll and Larry Bassel.