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:
1 parent
28efc67f5d
commit
c0663537cb
1683 files changed
+220064
No files matched your search
Binary file not shown.
@@ -0,0 +1,74 @@
|
||||
10 REM Lunar Lander
|
||||
20 REM By Diomidis Spinellis
|
||||
25 REM Compiler version
|
||||
30 PRINT "You aboard the Lunar Lander about to leave the spacecraft."
|
||||
60 GOSUB 4000
|
||||
70 GOSUB 1000
|
||||
80 GOSUB 2000
|
||||
90 GOSUB 3000
|
||||
100 LET H = H - V
|
||||
110 LET V = ((V + G) * 10 - U * 2) / 10
|
||||
120 LET F = F - U
|
||||
130 IF H > 0 THEN 80
|
||||
135 LET H = 0
|
||||
140 GOSUB 2000
|
||||
150 IF V > 5 THEN 200
|
||||
160 PRINT "Congratulations! This was a very good landing."
|
||||
170 GOSUB 5000
|
||||
180 GOTO 10
|
||||
200 PRINT "You have crashed."
|
||||
210 GOTO 170
|
||||
1000 REM Initialise
|
||||
1010 LET V = 70
|
||||
1020 LET F = 500
|
||||
1030 LET H = 1000
|
||||
1040 LET G = 2
|
||||
1050 RETURN
|
||||
2000 REM Print values
|
||||
2010 PRINT " Meter readings"
|
||||
2015 PRINT " --------------"
|
||||
2020 PRINT "Fuel (gal):"
|
||||
2030 PRINT F
|
||||
2040 GOSUB 2100 + 100 * (H != 0)
|
||||
2050 PRINT V
|
||||
2060 PRINT "Height (m):"
|
||||
2070 PRINT H
|
||||
2080 RETURN
|
||||
2100 PRINT "Landing velocity (m/sec):"
|
||||
2110 RETURN
|
||||
2200 PRINT "Velocity (m/sec):"
|
||||
2210 RETURN
|
||||
3000 REM User input
|
||||
3005 IF F == 0 THEN 3070
|
||||
3010 PRINT "How much fuel will you use?"
|
||||
3020 INPUT U
|
||||
3025 IF U < 0 THEN 3090
|
||||
3030 IF U <= F THEN 3060
|
||||
3040 PRINT "Sorry, you have not got that much fuel!"
|
||||
3045 PRINT F
|
||||
3050 GOTO 3010
|
||||
3060 RETURN
|
||||
3070 LET U = 0
|
||||
3080 RETURN
|
||||
3090 PRINT "No cheating please! Fuel must be >= 0."
|
||||
3100 GOTO 3010
|
||||
4000 REM Detachment
|
||||
4005 PRINT "Ready for detachment"
|
||||
4007 PRINT "-- COUNTDOWN --"
|
||||
4010 FOR I = 1 TO 11
|
||||
4020 PRINT 11 - I
|
||||
4025 GOSUB 4500
|
||||
4030 NEXT I
|
||||
4035 PRINT "You have left the spacecraft."
|
||||
4037 PRINT "Try to land with velocity less than 5 m/sec."
|
||||
4040 RETURN
|
||||
4500 REM Delay
|
||||
4510 FOR J = 1 TO 500
|
||||
4520 NEXT J
|
||||
4530 RETURN
|
||||
5000 PRINT "Do you want to play again? (0 = no, 1 = yes)"
|
||||
5010 INPUT Y
|
||||
5020 IF Y == 0 THEN 5040
|
||||
5030 RETURN
|
||||
5040 PRINT "Have a nice day."
|
||||
5050 END
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
# %W% %G% %U%
|
||||
#
|
||||
# 1991 makefile
|
||||
#
|
||||
# Copyright (c) 1991, 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
|
||||
MAKE=make
|
||||
MAKEFLAGS=e
|
||||
|
||||
# uncomment the line to select the preferred type of compile
|
||||
#
|
||||
# You should also check the ansi.mk or common.mk for the
|
||||
# proper compiler name and flags.
|
||||
#
|
||||
# NOTE ==> USE=ansi compile with an ANSI compiler by default
|
||||
#USE=ansi
|
||||
# NOTE ==> USE=common compile with a common K&R compiler by default
|
||||
#USE=common
|
||||
|
||||
WINNERS= ant brnstnd buzzard cdupont davidguy dds fine rince westley
|
||||
|
||||
all:
|
||||
-@if [ "${USE}" = "common" ]; then \
|
||||
echo ${MAKE} -k -f common.mk all; \
|
||||
${MAKE} -k -f common.mk all; \
|
||||
elif [ "${USE}" = "ansi" ]; then \
|
||||
echo ${MAKE} -k -f ansi.mk all; \
|
||||
${MAKE} -k -f ansi.mk all; \
|
||||
else \
|
||||
echo "set USE= in Makefile to be ansi or common as desired"; \
|
||||
echo "or type: make -f ansi.mk for ansi makes"; \
|
||||
echo "or type: make -f common.mk for common K&R makes"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
ansi:
|
||||
${MAKE} -f ansi.mk all
|
||||
|
||||
common:
|
||||
${MAKE} -f common.mk all
|
||||
|
||||
${WINNERS} merlyn.c nextmove.c ttt_game.c:
|
||||
-@if [ "${USE}" = "common" ]; then \
|
||||
echo ${MAKE} -f common.mk $@; \
|
||||
${MAKE} -f common.mk $@; \
|
||||
elif [ "${USE}" = "ansi" ]; then \
|
||||
echo ${MAKE} -f ansi.mk $@; \
|
||||
${MAKE} -f ansi.mk $@; \
|
||||
else \
|
||||
echo "set USE= in Makefile to be ansi or common as desired"; \
|
||||
echo "or type: make -f ansi.mk for ansi makes"; \
|
||||
echo "or type: make -f common.mk for common K&R makes"; \
|
||||
exit 1;\
|
||||
fi
|
||||
|
||||
ttt: ttt.sh
|
||||
-@if [ "${USE}" = "common" ]; then \
|
||||
echo ${MAKE} -f common.mk $@; \
|
||||
${MAKE} -f common.mk $@; \
|
||||
elif [ "${USE}" = "ansi" ]; then \
|
||||
echo ${MAKE} -f ansi.mk $@; \
|
||||
${MAKE} -f ansi.mk $@; \
|
||||
else \
|
||||
echo "set USE= in Makefile to be ansi or common as desired"; \
|
||||
echo "or type: make -f ansi.mk for ansi makes"; \
|
||||
echo "or type: make -f common.mk for common K&R makes"; \
|
||||
exit 1;\
|
||||
fi
|
||||
|
||||
merlyn: merlyn.c
|
||||
-@if [ "${USE}" = "common" ]; then \
|
||||
echo ${MAKE} -f common.mk $@; \
|
||||
${MAKE} -f common.mk $@; \
|
||||
elif [ "${USE}" = "ansi" ]; then \
|
||||
echo ${MAKE} -f ansi.mk $@; \
|
||||
${MAKE} -f ansi.mk $@ \
|
||||
else \
|
||||
echo "set USE= in Makefile to be ansi or common as desired"; \
|
||||
echo "or type: make -f ansi.mk for ansi makes"; \
|
||||
echo "or type: make -f common.mk for common K&R makes"; \
|
||||
exit 1;\
|
||||
fi
|
||||
|
||||
ttt_game: ttt_game.c
|
||||
-@if [ "${USE}" = "common" ]; then \
|
||||
echo ${MAKE} -f common.mk $@; \
|
||||
${MAKE} -f common.mk $@; \
|
||||
elif [ "${USE}" = "ansi" ]; then \
|
||||
echo ${MAKE} -f ansi.mk $@; \
|
||||
${MAKE} -f ansi.mk $@; \
|
||||
else \
|
||||
echo "set USE= in Makefile to be ansi or common as desired"; \
|
||||
echo "or type: make -f ansi.mk for ansi makes"; \
|
||||
echo "or type: make -f common.mk for common K&R makes"; \
|
||||
exit 1;\
|
||||
fi
|
||||
|
||||
nextmove: nextmove.c
|
||||
-@if [ "${USE}" = "common" ]; then \
|
||||
echo ${MAKE} -f common.mk $@; \
|
||||
${MAKE} -f common.mk $@; \
|
||||
elif [ "${USE}" = "ansi" ]; then \
|
||||
echo ${MAKE} -f ansi.mk $@; \
|
||||
${MAKE} -f ansi.mk $@; \
|
||||
else \
|
||||
echo "set USE= in Makefile to be ansi or common as desired"; \
|
||||
echo "or type: make -f ansi.mk for ansi makes"; \
|
||||
echo "or type: make -f common.mk for common K&R makes"; \
|
||||
exit 1;\
|
||||
fi
|
||||
|
||||
clean:
|
||||
${MAKE} -f ansi.mk clean
|
||||
${MAKE} -f common.mk clean
|
||||
clobber:
|
||||
${MAKE} -f ansi.mk clobber
|
||||
${MAKE} -f common.mk clobber
|
||||
nuke: clobber
|
||||
${MAKE} -f ansi.mk nuke
|
||||
${MAKE} -f common.mk nuke
|
||||
install:
|
||||
${MAKE} -f ansi.mk install
|
||||
${MAKE} -f common.mk install
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
1991 marked the "The Eighth International Obfuscated C Code Contest"
|
||||
|
||||
Copyright (c) 1991, 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 BSD 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, we did not single out an entry that was better than all of
|
||||
the rest. We selected 3 entries that were, in our opinion, went beyond
|
||||
all of the other entries this year:
|
||||
|
||||
Grand Prize by Brian Westley
|
||||
Most Well Rounded by Diomidis Spinellis
|
||||
Best Of Show by Daniel J. Bernstein
|
||||
|
||||
Name and address information are separated from the actual program
|
||||
prior to judging. This eliminates any chance that we would bias our
|
||||
judging for/against any person or group. In the end, we are surprised
|
||||
as you are to see who as won. Even so, it is worth noting that
|
||||
Brian Westley has submitted a winning entry for the past 5 years!
|
||||
|
||||
|
||||
A few notes regarding possible changes to the contest:
|
||||
|
||||
We did not give awards to some traditional contest categories such as
|
||||
"Best Layout" or "Worst Abuse of the Rules". We felt that to do so
|
||||
would deny awards to more deserving entries. These categories have not
|
||||
been eliminated, and will likely be considered in future years.
|
||||
|
||||
A number of entries made use of the following C pre-processor feature:
|
||||
|
||||
#define X define
|
||||
#X foo bar
|
||||
|
||||
This is not permitted under ANSI C. Some ANSI C compilers do allow
|
||||
this. In the future, we do not want programs to use this feature.
|
||||
Because this request was not stated in the 1991 rules, we did not
|
||||
reject entries of this type. However we provided more portable
|
||||
versions so that more people could compile these programs.
|
||||
|
||||
This year we received entries that made use of the X Window System.
|
||||
This functionality is now available on many systems, we feel that
|
||||
programs that use these are now portable enough to be valid entries.
|
||||
|
||||
We may allow programs to make use of the X Window System libs and include
|
||||
files, provided that they can operate with a system running at the level
|
||||
of at least X11r4. Requiring the use of imake, a specific window manager,
|
||||
specific display hardware, or a specific user interface (Openl**k,
|
||||
M*tif, ...) is likely not to be allowed. We will provide a more detailed
|
||||
explanation of our viewpoint in next year's rules.
|
||||
|
||||
In order to encourage more 'normal' looking C programs, we are considering
|
||||
the following change to the maximum size rule:
|
||||
|
||||
Your source, not counting any <space>, <tab>, and a <newline> character,
|
||||
and not counting any ';', '{' and '}' character followed by a <newline>
|
||||
character, must be 1536 bytes or less. The entire source, counting all
|
||||
characters, be 4096 bytes or less.
|
||||
|
||||
Some thought has been given to adding some c++ categories, however this
|
||||
is not likely to happen soon. We are waiting until c++ compilers become
|
||||
common place on a wide number of systems. We also need time to brace
|
||||
ourselves for what obfuscation c++ could wield!
|
||||
|
||||
Be sure to wait until the 1992 rules are posted before submitting entries.
|
||||
We may fine tune the rules to reflect the some ideas above.
|
||||
|
||||
Please send us comments and suggestions what we have expressed above.
|
||||
Also include anything else that you would like to see in future contests.
|
||||
Send such email to:
|
||||
|
||||
...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
|
||||
judges@toad.com
|
||||
|
||||
|
||||
Credits:
|
||||
|
||||
We would like to thank Barbara Frezza for her role as official chef
|
||||
of the contest. Landon Noll appreciated the opportunity to serve
|
||||
as assistant pizza chef. Larry Bassel was official taste tester. Yummo!
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
# %W% %G% %U%
|
||||
#
|
||||
# 1991 makefile
|
||||
|
||||
SHELL=/bin/sh
|
||||
CHMOD=chmod
|
||||
CP=cp
|
||||
RM=rm
|
||||
SED=sed
|
||||
LN=ln
|
||||
|
||||
# flags for ansi compiles
|
||||
#
|
||||
# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode,
|
||||
# others such as gcc may want -ansi, others may want nothing
|
||||
# at all. Adjust the CFLAGS line as needed.
|
||||
#
|
||||
CFLAGS=-O -Xa
|
||||
CC=cc
|
||||
|
||||
# winners that may be ok to compile with common K&R
|
||||
#
|
||||
WINNERS= ant brnstnd buzzard cdupont davidguy dds fine westley rince
|
||||
|
||||
all: ${WINNERS}
|
||||
|
||||
common:
|
||||
@echo "wrong makefile, use ansi.mk"
|
||||
exit 1
|
||||
|
||||
ansi: all
|
||||
|
||||
# NOTE: some systems may need:
|
||||
#
|
||||
# old SYS V:
|
||||
# cc ${CFLAGS} -DMODE=0600 -DBUF=32767 -o ant ant.c -lcurses
|
||||
# ATARI ST:
|
||||
# cc -DMODE=0 -DBUF=32767 -o ant.ttp ant.c curses.a
|
||||
# PC class:
|
||||
# wcl -mc -DMODE=0 -DBUF=32767 ant.c curses.lib
|
||||
#
|
||||
ant: ant.c
|
||||
${CC} ${CFLAGS} -DMODE=0600 -DBUF=32767 ant.c -o ant -lcurses -ltermcap
|
||||
|
||||
brnstnd: brnstnd_ansi.c
|
||||
${CC} ${CFLAGS} -DM=malloc -DX=free -Do=250 brnstnd_ansi.c -o brnstnd
|
||||
|
||||
buzzard: buzzard.c
|
||||
${CC} ${CFLAGS} buzzard.c -o buzzard
|
||||
|
||||
cdupont: cdupont_ansi.c
|
||||
${CC} ${CFLAGS} -Ds=\"cdupont.c\" -Dt=\"r\" cdupont_ansi.c -o cdupont
|
||||
|
||||
# NOTE: some systems may need:
|
||||
#
|
||||
# ${CC} ${CFLAGS} davidguy.c -o davidguy
|
||||
# or:
|
||||
# ${CC} ${CFLAGS} davidguy.c -o davidguy -linet
|
||||
#
|
||||
davidguy: davidguy.c
|
||||
${CC} ${CFLAGS} davidguy.c -o davidguy -lsocket -lnsl
|
||||
|
||||
# NOTE: this is the original program that won the contest
|
||||
#
|
||||
# BSD:
|
||||
# ${CC} ${CFLAGS} davidguy.orig.c -o davidguy.orig
|
||||
#
|
||||
davidguy.orig: davidguy.orig.c
|
||||
${CC} ${CFLAGS} davidguy.orig.c -o davidguy.orig -lsocket -lnsl
|
||||
|
||||
dds: dds.ansi.c LANDER.BAS
|
||||
${CC} ${CFLAGS} dds.ansi.c -o dds
|
||||
|
||||
fine: fine.c
|
||||
${CC} ${CFLAGS} fine.c -o fine
|
||||
|
||||
westley: westley.c ttt
|
||||
${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
westley.c -o westley
|
||||
|
||||
# the hint file gives nextmove.c as an example, provide a build rule for it
|
||||
#
|
||||
nextmove: nextmove.c ttt
|
||||
${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
nextmove.c -o nextmove
|
||||
|
||||
# the ttt script has been added by the judges to make playing westley easy
|
||||
#
|
||||
ttt: ttt.sh
|
||||
rm -f ttt
|
||||
cp ttt.sh ttt
|
||||
chmod +x ttt
|
||||
|
||||
# used by the ttt shell script when playing westley
|
||||
#
|
||||
# The ttt script controls what goes into merlyn.c, and how it is used.
|
||||
# The merlyn program and source represent the best (hopefully) state that
|
||||
# the program has evolved into thus far. The ttt_game program and source
|
||||
# represent the current state of the game.
|
||||
#
|
||||
merlyn: merlyn.c ttt
|
||||
@${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
merlyn.c -o merlyn
|
||||
ttt_game: ttt_game.c ttt
|
||||
@${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
ttt_game.c -o ttt_game
|
||||
|
||||
# The upper level makefile wants to make these source files if they don't
|
||||
# already exist.
|
||||
#
|
||||
merlyn.c: westley.c
|
||||
rm -f merlyn.c
|
||||
cp westley.c merlyn.c
|
||||
chmod +w merlyn.c
|
||||
nextmove.c: westley.c
|
||||
rm -f nextmove.c
|
||||
cp westley.c nextmove.c
|
||||
chmod +w nextmove.c
|
||||
ttt_game.c: westley.c
|
||||
rm -f ttt_game.c
|
||||
cp westley.c ttt_game.c
|
||||
chmod +w ttt_game.c
|
||||
|
||||
# NOTE: some systems may need:
|
||||
#
|
||||
# old SYS V:
|
||||
# cc ${CFLAGS} -o rince rince.c -lcurses
|
||||
#
|
||||
# The original source is found in rince.orig.c. Many ANSI compilers have
|
||||
# problems with it, so by default we use rince_ansi.c.
|
||||
#
|
||||
# GNU CC users can compile this with:
|
||||
#
|
||||
# gcc -ansi rince.orig.c -o rince -lcurses -ltermcap
|
||||
#
|
||||
rince: rince.c
|
||||
${CC} ${CFLAGS} rince_ansi.c -o rince -lcurses -ltermcap
|
||||
|
||||
clean:
|
||||
${RM} -f *.o a.out core merlyn new_merlyn.c
|
||||
clobber: clean
|
||||
${RM} -f ${WINNERS} a.c a.out davidguy.orig ttt
|
||||
${RM} -f merlyn merlyn.c nextmove.c nextmove.c
|
||||
${RM} -f ttt_game ttt_game.c ttt_old.c ttt_new.c nextmove
|
||||
nuke: clobber
|
||||
@true
|
||||
install: all
|
||||
cat ${WINNERS} > /dev/null
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#define T isspace(*(t=Z(p)))&&
|
||||
#define V return
|
||||
#define _ while
|
||||
int d,i,j,m,n,p,q,x,y;char*c,b[BUF],*f,*g=b,*h,k[]="hjklHJKL[]tbixWRQ",*t;
|
||||
char*Z(a){if(a<0)V b;V b+a+(b+a<g?0:h-g);}P(a)char*a;{V
|
||||
a-b-(a<h?0:h-g);}S(){p=0;}bf(){n=p=P(c);}Q(){q=1;}C(){clear();Y();}
|
||||
G(){t=Z(p);_(t<g)*--h= *--g;_(h<t)*g++= *h++;p=P(h);}B(){_(!T b<t)--p;_(T
|
||||
b<t)--p;}M(a){_(b<(t=Z(--a))&&*t-'\n');V
|
||||
b<t?++a:0;}N(a){_((t=Z(a++))<c&&*t-'\n');V
|
||||
t<c?a:P(c);}A(a,j){i=0;_((t=Z(a))<c&&*t-'\n'&&i<j){i+= *t-'\t'?1:8-(i&7);++a;}V
|
||||
a;}L(){0<p&&--p;}R(){p<P(c)&&++p;}U(){p=A(M(M(p)-1),x);}
|
||||
D(){p=A(N(p),x);}H(){p=M(p);}E(){p=N(p);L();}
|
||||
J(){m=p=M(n-1);_(0<y--)D();n=P(c);}K(){j=d;_(0<--j)m=M(m-1),U();}
|
||||
I(){G();_((j=getch())-'\f'){if(j-'\b')g-h&&(*g++=j-'\r'?j:'\n');else
|
||||
b<g&&--g;p=P(h);Y();}}X(){G();p=h<c?P(++h):p;}
|
||||
F(){j=p;p=0;G();write(i=creat(f,MODE),h,(int)(c-h));close(i);p=j;}W(){_(!T
|
||||
t<c)++p;_(T
|
||||
t<c)++p;}int(*z[])()={L,D,U,R,B,J,K,W,H,E,S,bf,I,X,F,C,Q,G};
|
||||
Y(){m=p<m?M(p):m;if(n<=p){m=N(p);i=m-P(c)?d:d-2;_(0<i--)m=M(m-1);}
|
||||
move(0,0);i=j=0;n=m;_(1){p-n||(y=i,x=j);t=Z(n);if(d<=i||c<=t)break;
|
||||
if(*t-'\r')addch(*t),j+= *t-'\t'?1:8-(j&7);if(*t=='\n'||COLS<=j)
|
||||
++i,j=0;++n;}clrtobot();++i<d&&mvaddstr(i,0,"<< EOF >>");move(y,x);
|
||||
refresh();}main(u,v)char**v;{h=c=b+BUF;if(u<2)V
|
||||
2;initscr();d=LINES;raw();noecho();idlok(stdscr,1);if(0<(i=open(f= *++v,0))){
|
||||
g+=read(i,b,BUF);g=g<b?b:g;close(i);}S();_(!q){Y();i=0;j=getch();
|
||||
_(k[i]&&j-k[i])++i;(*z[i])();}endwin();V 0;}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
Best Utility:
|
||||
|
||||
Anthony C Howe
|
||||
Mortice Kern Systems Inc. #CL-23
|
||||
35 King St. N 268 Phillip St.
|
||||
Waterloo, On Waterloo, On
|
||||
Canada, N2J 2W9 Canada, N2L 6G9
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run with a filename (writable or to be created) as an argument.
|
||||
For example, try:
|
||||
|
||||
make ant
|
||||
cp ant.hint hill
|
||||
ant hill
|
||||
|
||||
Note that some old BSD systems may have trouble compiling this entry.
|
||||
They may complain about 'idlok' being undefined. You can fix this
|
||||
by changing line 26 from:
|
||||
|
||||
2;initscr();d=LINES;raw();noecho();idlok(stdscr,1);if(0<(i= ...
|
||||
to:
|
||||
2;initscr();d=LINES;raw();noecho();if(0<(i= ...
|
||||
|
||||
***or*** update to a modern version of Un*x. :-) If you have source,
|
||||
you can use this entry to help in your upgrade.
|
||||
|
||||
You may need to change the makefile depending on what type of system
|
||||
you are running. See the notes in ansi.mk or common.mk.
|
||||
|
||||
The author was kind enough to supply a list of references below,
|
||||
in case you are still confused after read the source! :-)
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
Ant's Editor vIOCCC91
|
||||
|
||||
Text files consists of lines of printable text or tab characters.
|
||||
A line can be of arbitrary length and is delimited by either a
|
||||
newline or the end of file. 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
|
||||
h j k l left, down, up, right cursor movement
|
||||
H J K L word left, page down, page up, word right
|
||||
[ ] beginning and end of line
|
||||
t b top and bottom of file
|
||||
i enter insert mode, formfeed to quit
|
||||
x delete character under the cursor
|
||||
W write buffer to file
|
||||
R refresh the screen
|
||||
Q quit
|
||||
|
||||
EXIT STATUS
|
||||
0 success
|
||||
2 missing edit filename
|
||||
|
||||
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 the size of arrays & structures of 32k.
|
||||
Also the WatCom C compiler for the PC also has 16 bits ints. On
|
||||
machines that have 32 bit ints (most unix boxes), a larger value
|
||||
for BUF could be used.
|
||||
|
||||
It is recommend that compact memory model be used on PC class
|
||||
machines. Small memory model may work too provided BUF is not
|
||||
too large.
|
||||
|
||||
The character constants '\b', '\f', '\n', '\r', '\t' are used
|
||||
in order to provide more portable code, since the compiler should
|
||||
handle the translation of them into the native character set.
|
||||
Note that '\f' (formfeed) was used to exit insert mode because
|
||||
K&R C had no escape constant for the escape-key.
|
||||
|
||||
My goals for this project were to learn and experiment with the
|
||||
Buffer Gap Scheme [Fin80][net90], write a useful and *portable*
|
||||
programme, and meet the requirements of the IOCCC. I initially
|
||||
planned to have a mini CURSES built-in like the IOCCC Tetris entry
|
||||
from a previous year, however this was not as portable as using a
|
||||
CURSES library with TERMINFO/TERMCAP support.
|
||||
|
||||
I plan to post followups such as unobfuscated versions and bugs
|
||||
fixes to comp.editors. Reposts of the editor.101, gap.doc, and
|
||||
editor.102 can be found 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
|
||||
[Fin80] Craig A. Finseth, "Theory and Practice of Text Editors or
|
||||
A Cookbook For An EMACS", TM-165, MIT Lab. for Computer
|
||||
Science
|
||||
|
||||
[KeP81] Kernighan & Plauger, "Software Tools in Pascal",
|
||||
Addison-Wesley, 81, chapter 6
|
||||
|
||||
[Mil86] Eugene W. Myers & Webb Miller, "Row-replacement Algorithms
|
||||
for Screen Editors", TR 86-19, Dept. of Computer Science,
|
||||
U. of Arizona
|
||||
|
||||
[MyM86] Eugene W. Myers & Webb Miller, "A simple row-replacement
|
||||
method", TR 86-28, Dept. of Computer Science, U. of Arizona
|
||||
|
||||
[Mil87] Webb Miller, "A Software Tools Sampler", Prentice Hall, 87
|
||||
ISBN 0-13-822305-X, chapter 5
|
||||
|
||||
[net90] "Editor 101/102" articles from comp.editors
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#define D define
|
||||
#D H(x,y,z) f(p){--p;c=x-_+1];f(c>0){y+1]=z[c];z[c]=y];y]=y+1];}}
|
||||
#D O(x,y) F(x,int U;int T=0;d=M(U=1);W{f(c==y)b g[T++]=c;f(T==U)g=realloc(g,U<<=1);}g[T]=0;)
|
||||
#D W Y((c=k?K[--k]:getchar())-EOF)
|
||||
#D S i[q
|
||||
#D F(w,z) f(c==w){z h}
|
||||
#D f if
|
||||
#D P p>1&&(c=u,
|
||||
#D _ s[p
|
||||
#D C =G
|
||||
#D g S]
|
||||
#D J(x,y) F(I[x],y)
|
||||
#D Q P e
|
||||
#D Y while
|
||||
#D b break;
|
||||
#D u _--]
|
||||
#D m p&&
|
||||
#D R char*
|
||||
#D l Z[c]
|
||||
#D L strlen
|
||||
#D d i[++q]
|
||||
#D G c)
|
||||
#D h ;continue;
|
||||
#D N s[++p]
|
||||
#D e _]
|
||||
#D j x;{R r=M(L(
|
||||
#D v return
|
||||
#D w [256]
|
||||
#D V f(k>o||p>o||q>o)v 2;
|
||||
R I="I'd love ta win: the most useful !$>%`/#<&*|^ _OBFUSCATED_ utility. Pleez?";U(y,x)R y;R*j*x)+L(y)+1);sprintf(r,"%s%s",*x,y);*x=r;}R T(x)R j x)+1);strcpy(r,x);v
|
||||
r;}R(i w);static R(Z w);K w;main(a,A)int a;R*A;{int s w,p=0,q=0,n=0,c,k=0;W{V
|
||||
f(c>='0'&&c<='9'){f(!n)N=0;n=1;e=10*e+(c-'0')h}n=0;J(39,m
|
||||
sprintf(d=M(13),"%d",e))
|
||||
J(37,q&&puts(g))J(34,q&&printf("%s",g))J(27,H(p,_,s))O('[',']')J(56,f(p){c=e;N=c;})J(2,m--p)J(10,N=a)J(4,f(q){N=L(g);X(S--]);})J(1,f(q){S+1]=T(g);++q;})J(53,m
|
||||
e>=0&&e<a&&(d=T(A[u])))
|
||||
J(54,q>1&&(--q,U(S+1],i+q)))J(5,q&&p>1&&(_-1]=open(g,_-1],e),--p,X(S--])))J(47,m
|
||||
close(u))
|
||||
J(26,m(e=dup(e)))O('"','"')J(51,H(q,S,i))J(49,N=fork())J(12,wait(&N)+1||(e=-1))J(68,{++p;pipe(s+p++)==-1&&(e=-1);})F('q',v
|
||||
0)
|
||||
F('=',W{R x;f(m u)f(x=l){k+=n=L(x);V;Y(*x)K[--k]=*x++;k+=n;n=0;}b})J(15,f(q)W{l&&X(l);l=T(g);b})J(33,f(c=q){*i=g;g=0;Y(--q&&**(i+q))g++;f(q){N=execvp(*i,i+q+1);q=c;}})J(38,P
|
||||
c&&(e/C))
|
||||
J(35,Q=e>G)F('+',Q+C)J(42,Q*C)J(41,Q=~(e&G))J(57,m(e=-e))J(3,)F('\n',)putchar(c);puts(73+I);}}
|
||||
@@ -0,0 +1,175 @@
|
||||
Best Of Show:
|
||||
|
||||
Daniel J. Bernstein
|
||||
New York University
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run. Try:
|
||||
|
||||
make brnstnd
|
||||
brnstnd < sorta.i2+2
|
||||
|
||||
For info on more examples, read the sorta.README file.
|
||||
|
||||
The author wished to win the "most useful program" award and
|
||||
documented this in the source code. The judges were unmoved
|
||||
by this blatant attempt to influence the contest and rejected
|
||||
this idea... so we gave it the Best of Show award instead!!
|
||||
|
||||
NOTE: Due to minor problems with some ANSI C compilers, we have
|
||||
supplied a more portable ANSI version. See the top level
|
||||
README file for details.
|
||||
|
||||
NOTE: One should remove the final trailing newline to obtain the
|
||||
original source file. This step is not needed to compile
|
||||
this entry.
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
This is an interpreter for the programming language SORTA, a systems
|
||||
and numerical programming language with features sorta from C, sorta
|
||||
from FORTH, and sorta from Ada.
|
||||
|
||||
SORTA lets you manipulate files and spawn programs easily, has bitwise
|
||||
operators, and gives you absolutely brilliant error messages like '?'
|
||||
(that's the C bit). SORTA programs work with a stack (that's the FORTH
|
||||
bit)---actually two stacks, one for integers and one for strings. And
|
||||
all SORTA operations are strongly typed, detect practically any failure,
|
||||
and garbage-collect (that's the Ada bit).
|
||||
|
||||
SORTA also contains features you might not expect from such a small
|
||||
interpreter: arbitrary-length string input and concatenation, for
|
||||
instance, not to mention infinite-depth tail recursion.
|
||||
|
||||
SORTA ignores its arguments (though it makes them available to the
|
||||
script); it takes all commands, character by character, from its
|
||||
standard input. Unrecognized commands are repeated with a ?.
|
||||
|
||||
SORTA maintains an ``i stack'' for integers and an ``s stack'' for
|
||||
strings. It also keeps track of ``programs,'' one for each character.
|
||||
Operations are silently ignored if the relevant stacks are too low,
|
||||
except as noted for s, S, and !. If the i stack or s stack (or the stack
|
||||
of buffered macro commands) grows too high, SORTA will exit silently
|
||||
with exit code 2. (Compile parameter -Do=250 controls what ``too high''
|
||||
means; you should not make o larger than 250.) I don't think it's
|
||||
possible to crash the interpreter.
|
||||
|
||||
Here, then, is the SORTA programming language. All non-digits delimit
|
||||
numeric constants. Spaces and newlines are ignored except as numeric
|
||||
delimiters.
|
||||
|
||||
Basic operations:
|
||||
|
||||
q: quit
|
||||
number: push that number on top of the i stack
|
||||
"string": push that string on top of the s stack, no length limit
|
||||
[string]: push that string on top of the s stack, no length limit
|
||||
#: make top of i stack non-destructively in ASCII, push result onto s stack
|
||||
`: print top of s stack non-destructively
|
||||
$: print top of s stack non-destructively without newline
|
||||
d: drop (pop) top of i stack
|
||||
D: dup (duplicate) top of i stack
|
||||
': dup top of s stack
|
||||
s: pop top of i stack. If it is n, swap (n+1)th-top of i stack with top.
|
||||
1s, for example, swaps the top two elements; 2s swaps the top with
|
||||
the third down; etc. This always pops the top of the i stack, even
|
||||
upon failure.
|
||||
S: pop top of i stack, then act just like s but upon s stack
|
||||
l: pop top of s stack, push its length onto i stack
|
||||
a: push argc onto i stack
|
||||
A: pop top of i stack, push argv[i] on top of s stack
|
||||
T: concatenate top two elements of s stack
|
||||
_: negate top of i stack
|
||||
+: pop top two elements of i stack, add, push back sum
|
||||
*: pop top two elements of i stack, multiply, push back product
|
||||
/: pop top two elements of i stack, divide, push back quotient
|
||||
>: pop top two elements of i stack, compare, push back 1 or 0 as in C
|
||||
&: pop top two elements of i stack, nand, push back bitwise result
|
||||
Note that nand is sufficient to construct all bitwise operations,
|
||||
as demonstrated by icalc below.
|
||||
|
||||
System operations:
|
||||
|
||||
o: pop top of s stack and top two of i stack; open(s1,i2,i1); leave
|
||||
result on i stack
|
||||
O: pop top of i stack, close() it
|
||||
u: pop top of i stack, dup() it, push result back on
|
||||
F: fork(), push result on i stack. This is not always safe while SORTA
|
||||
is reading keyboard input or a script, as the forked programs share
|
||||
file descriptors. It is always safe inside a program (see below).
|
||||
P: pipe(), push two ends <p0> <p1> onto i stack. In case of trouble,
|
||||
push <?> <-1> onto i stack.
|
||||
w: wait(), push successful result (or -1 if no children) on i stack
|
||||
!: execvp() top of the s stack. Arguments are the next things down on
|
||||
the s stack, in reverse order from popping; the first character of
|
||||
each string is lopped off. There must be an empty string somewhere
|
||||
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:
|
||||
|
||||
: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
|
||||
labeled by character x. Note that a digit at the end of a program
|
||||
will merge with any digits after =x; in that case you usually want
|
||||
to add a space at the end of the program.
|
||||
|
||||
Common idioms: To drop the top of the s stack, ld. To do a <, 1s>. To
|
||||
unconditionally execute the program labeled by character x, 1=x (or any
|
||||
nonzero number followed by =x). To print the top of the i stack
|
||||
non-destructively, #` (or #$ if you don't want the newline). To
|
||||
subtract, _+. To do mod or and or any of the other missing operations,
|
||||
combine the available operations as illustrated below. To introduce a
|
||||
comment, [ this is a comment string which is promptly eliminated ]ld.
|
||||
|
||||
SORTA's requirements: it wants fork(), execvp(), open(),
|
||||
close(), dup(), pipe(), and wait(), so it obviously won't even compile
|
||||
on a non-UNIX machine. It also assumes that you have a size-256
|
||||
character set and that the characters between '0' and '9' are exactly
|
||||
the digits in order. It does *not* depend on ASCII, despite the code
|
||||
appearance. Also note that SORTA does not attempt to declare malloc(),
|
||||
so you will get some warnings about illegal pointer combinations. Also
|
||||
note that there are unreached statements in SORTA.
|
||||
|
||||
While the program source of course depends highly on #defines for
|
||||
obfuscation, I like to think that this code has those little touches,
|
||||
those professionally sharpened edges that mark true software
|
||||
engineering. Observe, for instance, how i and s are the string and
|
||||
integer stacks respectively. It's these little things that make you
|
||||
feel at home in an otherwise utterly useless piece of code. They're
|
||||
what make an obfuscation work.
|
||||
|
||||
The character pool (``I'' after cpp) makes it rather painful to
|
||||
see the effect of commands at a glance. I can just imagine people
|
||||
spending hours bouncing between the pool and the rest of the code,
|
||||
or accidentally changing the pool without realizing its importance.
|
||||
Without documentation and example scripts, someone would find it
|
||||
a challenge to figure out what the arrays are used for, let alone
|
||||
that SORTA is a scripting language.
|
||||
|
||||
Another nice feature is that the SORTA language itself encourages
|
||||
you to write not merely obfuscated but plain incomprehensible
|
||||
scripts (like the examples below---after working with the language
|
||||
for a while, I guess I can read it pretty easily, but I also think
|
||||
FORTH is a beautiful language). The numbers running around
|
||||
everywhere will make people think of ASCII, even though the code is
|
||||
not ASCII-dependent. What's your first thought when you see
|
||||
several arrays[256]? This is pretty standard obfuscation otherwise.
|
||||
I like the way that unbalanced macro braces can throw off the
|
||||
reader in ``if(c>0){y+1]=z[c];'', and I had fun covering the
|
||||
alphabet with #defines, but that's nothing special.
|
||||
|
||||
Possible future extensions to SORTA include string extraction and
|
||||
matching, reading from files into strings, and encrypting the string
|
||||
pool to further confuse the judges. I don't think I can fit this into
|
||||
the size limit, unfortunately.
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#define H(x,y,z) f(p){--p;c=x-_+1];f(c>0){y+1]=z[c];z[c]=y];y]=y+1];}}
|
||||
#define O(x,y) F(x,int U;int T=0;d=M(U=1);W{f(c==y)b g[T++]=c;f(T==U)g=realloc(g,U<<=1);}g[T]=0;)
|
||||
#define W Y((c=k?K[--k]:getchar())-EOF)
|
||||
#define S i[q
|
||||
#define F(w,z) f(c==w){z h}
|
||||
#define f if
|
||||
#define P p>1&&(c=u,
|
||||
#define _ s[p
|
||||
#define C =G
|
||||
#define g S]
|
||||
#define J(x,y) F(I[x],y)
|
||||
#define Q P e
|
||||
#define Y while
|
||||
#define b break;
|
||||
#define u _--]
|
||||
#define m p&&
|
||||
#define R char*
|
||||
#define l Z[c]
|
||||
#define L strlen
|
||||
#define d i[++q]
|
||||
#define G c)
|
||||
#define h ;continue;
|
||||
#define N s[++p]
|
||||
#define e _]
|
||||
#define j x;{R r=M(L(
|
||||
#define v return
|
||||
#define w [256]
|
||||
#define V f(k>o||p>o||q>o)v 2;
|
||||
R I="I'd love ta win: the most useful !$>%`/#<&*|^ _OBFUSCATED_ utility. Pleez?";U(y,x)R y;R*j*x)+L(y)+1);sprintf(r,"%s%s",*x,y);*x=r;}R T(x)R j x)+1);strcpy(r,x);v
|
||||
r;}R(i w);static R(Z w);int K w;main(a,A)int a;R*A;{int s w,p=0,q=0,n=0,c,k=0;W{V
|
||||
f(c>='0'&&c<='9'){f(!n)N=0;n=1;e=10*e+(c-'0')h}n=0;J(39,m
|
||||
sprintf(d=M(13),"%d",e))
|
||||
J(37,q&&puts(g))J(34,q&&printf("%s",g))J(27,H(p,_,s))O('[',']')J(56,f(p){c=e;N=c;})J(2,m--p)J(10,N=a)J(4,f(q){N=L(g);X(S--]);})J(1,f(q){S+1]=T(g);++q;})J(53,m
|
||||
e>=0&&e<a&&(d=T(A[u])))
|
||||
J(54,q>1&&(--q,U(S+1],i+q)))J(5,q&&p>1&&(_-1]=open(g,_-1],e),--p,X(S--])))J(47,m
|
||||
close(u))
|
||||
J(26,m(e=dup(e)))O('"','"')J(51,H(q,S,i))J(49,N=fork())J(12,wait(&N)+1||(e=-1))J(68,{++p;pipe(s+p++)==-1&&(e=-1);})F('q',v
|
||||
0)
|
||||
F('=',W{R x;f(m u)f(x=l){k+=n=L(x);V;Y(*x)K[--k]=*x++;k+=n;n=0;}b})J(15,f(q)W{l&&X(l);l=T(g);b})J(33,f(c=q){*i=g;g=0;Y(--q&&**(i+q))g++;f(q){N=execvp(*i,i+q+1);q=c;}})J(38,P
|
||||
c&&(e/C))
|
||||
J(35,Q=e>G)F('+',Q+C)J(42,Q*C)J(41,Q=~(e&G))J(57,m(e=-e))J(3,)F('\n',)putchar(c);puts(73+I);}}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#define X(s) (!(s&3)-((s&3)==2))
|
||||
#define W while
|
||||
char Z[82][82],A,B,f,g=26;z(q){return atoi(q);}m(d,l){return
|
||||
Z[ B + X ( f +
|
||||
3) * d+l *X(f+ 2 )][ A+X ( f ) * d +
|
||||
l* X ( f + 3 ) ] ;}int
|
||||
h= 0;D(p,s)char*s; {W(h>>3<p>> 3 ) {putchar('\t'
|
||||
); h = ( h +8
|
||||
)&~7 ;}W(h < p ){putchar(' ');++h; }(void)printf(
|
||||
"%s" , s ) ;h+=strlen(s);}main(x,a)char **a; {
|
||||
# define P(x) (x?(5-(x))*(6-(x ))/2:11)
|
||||
int b; { char b[256],i, j=0; FILE*F;F=fopen(x-1?a[1]:"buzzard.c","r");W(
|
||||
fgets( b ,256 ,F)){for(i=0;b[ i];++ i)
|
||||
Z[j][i ] =( b [ i ] ==' '?1:2*(b[i]==(x>2?*a[2]:'\\')));++j;}fclose
|
||||
(F);}A =4 ; B = 3 ; f = 1;x >3? A=z(a[3]),B=z(a[4]):0;b='\n';do{if(b=='\n'
|
||||
){int y , s , d , p , q ,i;for
|
||||
(y=-11; y<= 11;++ y){ for(s = 1 ,d=0;s+3;s-=2){for
|
||||
(;d!=2 + 3 * s ; d+=s){
|
||||
if(m(d,0) !=1 ){p=P (d) ;if (abs( y )
|
||||
<p&& ! m ( d , 0 )||abs(y)>p)break;for
|
||||
(i =-p;i<p;++i)D(g+i*2,"--");D(0,"\-");break;}if(d==5)continue;
|
||||
p=P(d+1);q=P(d);if
|
||||
(abs(y) >q)continue;if
|
||||
(abs(y) <p)D(g-s*(2*p+1),"|");else if(m(d,s)){if
|
||||
(abs(y) <=p)for(i=(s==1?-q:p);i!=(s==1?-p:q);
|
||||
(abs(y) ),++i)D(g+2*i+(s==-1),"--");}else if
|
||||
(abs(y) ==p)D(g-s*(2*p+1),"|");else D(g-
|
||||
(abs(y) *s*2),(s==1)^(y>0)?"\\":"/");}d-=s;}puts(
|
||||
"");h=0;}}f+=(b=='r')-(b=='l');f&=3;if(b=='f'){if(!m(1,0))continue;
|
||||
A+=X(f);B+=X(f-1);}}W((b=getchar())!=-1&&m(0,0)==1);return 0;}
|
||||
@@ -0,0 +1,92 @@
|
||||
Best Output:
|
||||
|
||||
Sean Barrett
|
||||
University of Maryland
|
||||
5407 20th Place
|
||||
Hyattsville MD 20782
|
||||
USA
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run as follows:
|
||||
|
||||
make buzzard
|
||||
buzzard
|
||||
|
||||
You will be A-mazed.
|
||||
|
||||
You are invited to try to cheat, ... if you can figure out how! :-)
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
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
|
||||
return. To turn 90 degrees right, type 'r'; left, 'l'. You can
|
||||
put multiple commands on one line, and the new view will be drawn
|
||||
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.
|
||||
|
||||
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
|
||||
znexf gur cynpr jurer lbh pna rfpncr gur znmr?
|
||||
|
||||
Gur nytbevguz vf dhvgr ovmneer--gur cevznel arfgrq ybbc gung
|
||||
trarengrf vg tbrf gbc gb obggbz ba gur qvfcynl, ybbcvat sbejneq
|
||||
gura onpxjneq sebz gur pheerag cbfvgvba gb qenj gur yrsg fvqr naq
|
||||
gura gur evtug fvqr.
|
||||
|
||||
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
|
||||
frcnengr culfvpny ebjf va gur znmr; n fcnpr vaqvpngrf n pbeevqbe,
|
||||
naq nal bgure punenpgre vf n jnyy. Gnof ner nyfb pbafvqrerq jnyyf,
|
||||
fb znxr fher gb pbaireg gnof gb fcnprf orsber hfvat vg.
|
||||
|
||||
Hfntr: ohmmneq [svyranzr [rfpncr-pune [fgneg-k fgneg-l]]]
|
||||
|
||||
Svyranzr vf gur anzr bs gur svyr pbagnvavat gur znmr. Guvf
|
||||
qrsnhygf gb 'ohmmneq.p'.
|
||||
|
||||
Rfpncr-pune vf gur punenpgre va gur znmr gung ercerfragf gur rkvg.
|
||||
Lbh pna chg zber guna bar rkvg va gur znmr (sbe rknzcyr, lbh pbhyq
|
||||
znxr nyy '!'f va gur znmr or rkvgf).
|
||||
|
||||
Fgneg-k naq fgneg-l znex gur pbbeqvangrf jurer lbh ortva cynlvat.
|
||||
L pbbeqvangr vf qbja gur ebjf va gur svyrf, K vf gb gur evtug
|
||||
guebhtu gur punenpgref bs rnpu yvar. Obgu K naq L ortva pbhagvat
|
||||
sebz 0. Gur qrsnhyg vf fgneg-k = 4, fgneg-l = 5, juvpu vf arrqrq
|
||||
sbe gur ohmmneq.p, ohg jbhyq cebonoyl or vanccebcevngr sbe bgure
|
||||
znmrf.
|
||||
|
||||
OHTF:
|
||||
|
||||
Lbh pna'g punatr gung ng fgneg lbh'er snpvat qbja ("fbhgu").
|
||||
|
||||
Gur qenjvat nytbevguz pnaabg unaqyr bcra fcnprf (gjb fhpprfvir
|
||||
fvqr-pbeevqbef jvgu ab jnyy orgjrra gurz). Va snpg, vg pnaabg unaqyr
|
||||
fznyy qbt-yrtf cebcreyl, nygubhtu gur reebe vf fhogyr.
|
||||
|
||||
Gur rkvg vf qenja yvxr n abezny pbeevqbe sebz gur fvqr ivrj;
|
||||
vg'f bayl qvfcynlrq nf gur rkvg jura lbh ner snpvat vg.
|
||||
|
||||
Vzcebcre pbzznaqyvar nethzragf ner abg unaqyrq avpryl.
|
||||
|
||||
Znmrf jvgu bcravatf ng gur rqtrf jvyy pnhfr gur qenjvat cebtenz
|
||||
gb ernpu vagb neovgenel cnepryf bs zrzbel.
|
||||
|
||||
Gur cebtenz nffhzrf gung gnof ner frg gb 8 punenpgref.
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1,26 @@
|
||||
/* common sense to nohonest programmer */
|
||||
#include <stdio.h>
|
||||
main(){int x ,gi=4,i,f,ri=1,httxkbl=1,m=012;long cd=0x5765248d,n;
|
||||
char u[0x50][032];FILE *ind;
|
||||
ind=fopen(s,t); for(i=0; i<0x1a; i++){goto daswjhkls;vhjsgfdy1l1gjhd:;}
|
||||
/*borntorun.*/goto c0g0;cOgO:i=0;fclose(ind);c0gO:
|
||||
x= u [gi][m]; sorryfor_this_unused_but_very_needed_label:
|
||||
if( m==gi){x=0x70;f=0x68;}else goto cOg0 ; b:putchar(x); if(
|
||||
!(n-httxkbl++))
|
||||
#define yank putchar('
|
||||
{httxkbl=1; yank ');goto
|
||||
hxi;}goto bl;
|
||||
/* hardlyundrstandable, but
|
||||
likely to be missed if removed */
|
||||
daswjhkls: fgets(u[i], 0120, ind);
|
||||
/*obfuscated, eh? */goto
|
||||
vhjsgfdy1l1gjhd;
|
||||
c0g0 : n=cd&0x40000000L>>0x1e;
|
||||
goto cOgO; g6w:
|
||||
if(x!=0x2e){i++;goto c0gO;}else /*
|
||||
injail*/yank\n');goto vhjsgfdyl1lgjhd;
|
||||
cOg0 :
|
||||
f=u[m][gi];goto b;bl:m=(i+1)*(4*
|
||||
x+3*f)%032;gi=(i+1)*(x+2*f)%0x1a; goto g6w;
|
||||
hxi:cd^= n= cd&(7<<3*(014-++ri));
|
||||
n >>=3*(12-ri); goto bl;vhjsgfdyl1lgjhd:;}
|
||||
@@ -0,0 +1,54 @@
|
||||
Most Useful Label:
|
||||
|
||||
Christian Dupont
|
||||
Ecole Normale Superieure de Lyon,
|
||||
Laboratoire d'Informatique Parallele
|
||||
42, Rue H.Berlioz
|
||||
69009 Lyon
|
||||
France
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run as follows:
|
||||
|
||||
make cdupont
|
||||
cdupont
|
||||
|
||||
Why is the following label necessary?
|
||||
|
||||
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... :-))
|
||||
|
||||
NOTE: Due to minor problems with some ANSI C compilers, we have
|
||||
supplied a more portable ANSI version. See the top level
|
||||
README file for details.
|
||||
|
||||
NOTE: One should remove the final trailing newline to obtain the
|
||||
original source file. This step is not needed to compile
|
||||
this entry.
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
Spoiler, rot13 to read:
|
||||
|
||||
Gur fbhepr pbqr ubyqf gur yrggref bs gur zrffntr. Rnpu yrggre, pbzovarq
|
||||
jvgu nabgure xrl yrggre, vf hfrq gb pbzchgr gur pbbeqvangrf bs gur arkg
|
||||
yrggre naq xrl. Guhf, gur zrffntr vf pbqr. Gung vf jul V hfr fvyyl
|
||||
pbzzragf, zbfg bsgra onqyl fcnprq.
|
||||
|
||||
Gur fcnpr punenpgre frdhrapr orgjrra gur jbeqf vf tvira ol n fvzcyr
|
||||
pbzchgngvba ba na bpgny pbafgnag (tvira urer nf na urk inyhr, bs
|
||||
pbhefr).
|
||||
|
||||
Guvf jnl, nal zrffntr pna or zvkrq vagb n pbqr, fvapr gur xrlf nyybj
|
||||
lbh gb cynpr gur zrnavatshy yrggref jurerire lbh jnag.
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1,26 @@
|
||||
/* common sense to nohonest programmer */
|
||||
#include <stdio.h>
|
||||
main(){int x ,gi=4,i,f,ri=1,httxkbl=1,m=012;long cd=0x5765248d,n;
|
||||
char u[0x50][032];FILE *ind;
|
||||
ind=fopen(s,t); for(i=0; i<0x1a; i++){goto daswjhkls;vhjsgfdy1l1gjhd:;}
|
||||
/*borntorun.*/goto c0g0;cOgO:i=0;fclose(ind);c0gO:
|
||||
x= u [gi][m]; sorryfor_this_unused_but_very_needed_label:
|
||||
if( m==gi){x=0x70;f=0x68;}else goto cOg0 ; b:putchar(x); if(
|
||||
!(n-httxkbl++))
|
||||
#define yank(x) putchar(x)
|
||||
{httxkbl=1; yank(' ');goto
|
||||
hxi;}goto bl;
|
||||
/* hardlyundrstandable, but
|
||||
likely to be missed if removed */
|
||||
daswjhkls: fgets(u[i], 0120, ind);
|
||||
/*obfuscated, eh? */goto
|
||||
vhjsgfdy1l1gjhd;
|
||||
c0g0 : n=cd&0x40000000L>>0x1e;
|
||||
goto cOgO; g6w:
|
||||
if(x!=0x2e){i++;goto c0gO;}else /*
|
||||
injail*/yank('\n');goto vhjsgfdyl1lgjhd;
|
||||
cOg0 :
|
||||
f=u[m][gi];goto b;bl:m=(i+1)*(4*
|
||||
x+3*f)%032;gi=(i+1)*(x+2*f)%0x1a; goto g6w;
|
||||
hxi:cd^= n= cd&(7<<3*(014-++ri));
|
||||
n >>=3*(12-ri); goto bl;vhjsgfdyl1lgjhd:;}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
# %W% %G% %U%
|
||||
#
|
||||
# 1991 makefile
|
||||
|
||||
SHELL=/bin/sh
|
||||
CHMOD=chmod
|
||||
CP=cp
|
||||
RM=rm
|
||||
SED=sed
|
||||
LN=ln
|
||||
|
||||
# flags for common K&R compiles
|
||||
#
|
||||
CFLAGS=-O
|
||||
CC=cc
|
||||
|
||||
# winners that may be ok to compile with common K&R
|
||||
#
|
||||
WINNERS= ant brnstnd buzzard cdupont davidguy dds fine westley rince
|
||||
|
||||
all: ${WINNERS}
|
||||
|
||||
ansi:
|
||||
@echo "wrong makefile, use ansi.mk"
|
||||
exit 1
|
||||
|
||||
common: all
|
||||
|
||||
# NOTE: some systems may need:
|
||||
#
|
||||
# old SYS V:
|
||||
# cc ${CFLAGS} -DMODE=0600 -DBUF=32767 -o ant ant.c -lcurses
|
||||
# ATARI ST:
|
||||
# cc -DMODE=0 -DBUF=32767 -o ant.ttp ant.c curses.a
|
||||
# PC class:
|
||||
# wcl -mc -DMODE=0 -DBUF=32767 ant.c curses.lib
|
||||
#
|
||||
ant: ant.c
|
||||
${CC} ${CFLAGS} -DMODE=0600 -DBUF=32767 ant.c -o ant -lcurses -ltermcap
|
||||
|
||||
brnstnd: brnstnd.c
|
||||
${CC} ${CFLAGS} -DM=malloc -DX=free -Do=250 brnstnd.c -o brnstnd
|
||||
|
||||
buzzard: buzzard.c
|
||||
${CC} ${CFLAGS} buzzard.c -o buzzard
|
||||
|
||||
cdupont: cdupont.c
|
||||
${CC} ${CFLAGS} -Ds=\"cdupont.c\" -Dt=\"r\" cdupont.c -o cdupont
|
||||
|
||||
# NOTE: some systems may need:
|
||||
#
|
||||
# ${CC} ${CFLAGS} davidguy.c -o davidguy
|
||||
# or:
|
||||
# ${CC} ${CFLAGS} davidguy.c -o davidguy -linet
|
||||
#
|
||||
davidguy: davidguy.c
|
||||
${CC} ${CFLAGS} davidguy.c -o davidguy -lsocket -lnsl
|
||||
|
||||
# NOTE: this is the original program that won the contest
|
||||
#
|
||||
# BSD:
|
||||
# ${CC} ${CFLAGS} davidguy.orig.c -o davidguy.orig
|
||||
#
|
||||
davidguy.orig: davidguy.orig.c
|
||||
${CC} ${CFLAGS} davidguy.orig.c -o davidguy.orig -lsocket -lnsl
|
||||
|
||||
dds: dds.c LANDER.BAS
|
||||
${CC} ${CFLAGS} dds.c -o dds
|
||||
|
||||
fine: fine.c
|
||||
${CC} ${CFLAGS} fine.c -o fine
|
||||
|
||||
westley: westley.c ttt
|
||||
${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
westley.c -o westley
|
||||
|
||||
# the hint file gives nextmove.c as an example, provide a build rule for it
|
||||
#
|
||||
nextmove: nextmove.c ttt
|
||||
${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
nextmove.c -o nextmove
|
||||
|
||||
# the ttt script has been added by the judges to make playing westley easy
|
||||
#
|
||||
ttt: ttt.sh
|
||||
rm -f ttt
|
||||
cp ttt.sh ttt
|
||||
chmod +x ttt
|
||||
|
||||
# used by the ttt shell script when playing westley
|
||||
#
|
||||
# The ttt script controls what goes into merlyn.c, and how it is used.
|
||||
# The merlyn program and source represent the best (hopefully) state that
|
||||
# the program has evolved into thus far. The ttt_game program and source
|
||||
# represent the current state of the game.
|
||||
#
|
||||
merlyn: merlyn.c ttt
|
||||
@${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
merlyn.c -o merlyn
|
||||
ttt_game: ttt_game.c ttt
|
||||
@${CC} ${CFLAGS} -DP=putchar -DN="P(10)" -DQ="P(34)" -DF="S(&X)" \
|
||||
-DJ=z[4] -DK=J[14] \
|
||||
-DH="w[]={146,7,292,73,448,56,84,273,325,297,108,324,22,40,48,40,17,325}" \
|
||||
ttt_game.c -o ttt_game
|
||||
|
||||
# The upper level makefile wants to make these source files if they don't
|
||||
# already exist.
|
||||
#
|
||||
merlyn.c: westley.c
|
||||
rm -f merlyn.c
|
||||
cp westley.c merlyn.c
|
||||
chmod +w merlyn.c
|
||||
nextmove.c: westley.c
|
||||
rm -f nextmove.c
|
||||
cp westley.c nextmove.c
|
||||
chmod +w nextmove.c
|
||||
ttt_game.c: westley.c
|
||||
rm -f ttt_game.c
|
||||
cp westley.c ttt_game.c
|
||||
chmod +w ttt_game.c
|
||||
|
||||
# NOTE: some systems may need:
|
||||
#
|
||||
# old SYS V:
|
||||
# cc ${CFLAGS} -o rince rince.c -lcurses
|
||||
#
|
||||
# The original source is found in rince.orig.c. Many ANSI compilers have
|
||||
# problems with it, so by default we use rince_ansi.c.
|
||||
#
|
||||
# GNU CC users can compile this with:
|
||||
#
|
||||
# gcc -ansi rince.orig.c -o rince -lcurses -ltermcap
|
||||
#
|
||||
rince: rince.c
|
||||
${CC} ${CFLAGS} rince.c -o rince -lcurses -ltermcap
|
||||
|
||||
clean:
|
||||
${RM} -f *.o a.out core
|
||||
clobber: clean
|
||||
${RM} -f ${WINNERS} a.c a.out davidguy.orig ttt
|
||||
${RM} -f merlyn merlyn.c nextmove.c nextmove.c
|
||||
${RM} -f ttt_game ttt_game.c ttt_old.c ttt_new.c nextmove
|
||||
nuke: clobber
|
||||
@true
|
||||
install: all
|
||||
cat ${WINNERS} > /dev/null
|
||||
@@ -0,0 +1,33 @@
|
||||
#define u unsigned
|
||||
#define w char*
|
||||
#define j(x)(*(*(x*)&T)++)
|
||||
#define H j(short*)
|
||||
#define K j(w)
|
||||
#define e j(u*)
|
||||
#define r register u
|
||||
#define R(b)write(A,T=h,4*b);
|
||||
#define S (u*)sbrk(Q*4+U*8)+U
|
||||
#define E(a,b,c)a=c&1<<31|b/2;c=c*2|b&1;
|
||||
#define V q=h^*L;L+=F;E(d,q,x)E(f,d,s)g=f&q;f^=q
|
||||
#define W while(
|
||||
#define Z q=I&f;M|=q&c;c^=q;I^=f;M|=g&c;c^=g
|
||||
#define Y W(F= *s++-'0')<=9)*T=10**T+F;K
|
||||
#define D(q,s)c);W q>s)G= *--q,*q= *s,*s++=G;
|
||||
#define P if(i^z){x=Q+(n=D(x,n)
|
||||
#define C if(i){q=Q*4+(s=(w)D(q,s)
|
||||
u A,U,Q,J,X[9999],B;main(a,b)w*b;{r*c,*d,y=0,f,g,F,I,M,N,z,*x,*n,i,G;w q,*h=(w
|
||||
)X,*T,*s=".slo.-W00,tmhw.W/";T=h;if(a>1){e;s=b[1];Y;Y;Y;Y;T=h;H;K=23;Y+=112;T=
|
||||
h;Y;y= *--T;H=2;}else{H=1;W*s)K=1+*s++;}connect(A=socket(a,1,0),T=h,24-a*4);H=
|
||||
17004;H=11;e=0;e=0;i=66==*h;R(3)read(A,h,8);e;H;read(A,h,4*H);T=h;e;F=e;e;e;I=
|
||||
11+H;f=H-6;K;U=K;i^=K;z=!K;T+=I/4*4+8*U;W y--){T+=39;I=K;W I--)H,T+=4+24*H;}I=
|
||||
e;e;B=(!e^**b&1)-1;e;e;U=H/32;J=H/30*30;T+=14;M=K;f/=U;T=h;K=55;K;H=4;e=F;e=I;
|
||||
e=0;R(4)N=F+8192;K=53;K=M;H=4;e=N;e=I;H=U*32;H=J;R(4)K=2;K;H=4;e=I;e=1;e=N;R(4
|
||||
)Q=J*U;c=S;d=S;L(c);W 1){P}C}y=0;W y<J){K=72;K=0;g=J-y;H=6+U*(g>f?g=f:g);e=N;e
|
||||
=F;H=U*32;H=g;H=0;H=y;K=0;K=1;R(6)write(A,c+y*U,g*U*4);y+=g;}K=61;K=0;H=4;e=I;
|
||||
e=0;e=0;R(4)C}P}v(c,d);}}L(A)r*A;{r*T=A+Q,X=getpid();W A<T)*A++=X=3*X^X/2;}v(n
|
||||
,O)u*n,*O;{r*A,F=U,*L=n-F,*G=L+Q,I,c,d,M,f,g,N,q,i=0,X,T,v,s,x,*y,*z,h=B;W L<n
|
||||
){*L= *G;G++[F]=L++[F];}W i<J){z=O+i*F;y=n+i*F-F;i+=30;L=y-1;A=L+U*32;W L<A){L
|
||||
+=F;E(X,(*L^h),x)E(q,X,s)}X=0;W X++<F){L=y++;G=z++;V;c=g|f&d;I=f^d;V;W L<=A){M
|
||||
=0;Z;N=d;T=f;v=g;V;Z;c^=I&d;*G=h^c&~M&(I^d|N);G+=F;c=v|T&N;I=T^N;}}}z=O;y=n;I=
|
||||
J;W--I!=-1){f= *z>>31;G=z+F;L=y+F;W G>z){M= *--G;*--L=(M*2)+f;f=M>>31;}z+=F;y+
|
||||
=F;}}
|
||||
@@ -0,0 +1,34 @@
|
||||
#define u unsigned
|
||||
#define w char*
|
||||
#define j(x)(*(*(x*)&T)++)
|
||||
#define H j(short*)
|
||||
#define K j(w)
|
||||
#define e j(u*)
|
||||
#define r register u
|
||||
#define R(b)write(A,T=h,4*b);
|
||||
#define S (u*)sbrk(Q*4+U*8)+U
|
||||
#define E(a,b,c)a=c&1<<31|b/2;c=c*2|b&1;
|
||||
#define V q= *L;L+=F;E(d,q,x)E(f,d,s)g=f&q;f^=q
|
||||
#define W while(
|
||||
#define Z q=I&f;M|=q&c;c^=q;I^=f;M|=g&c;c^=g
|
||||
#define Y W(F= *s++)&16)*T=10**T+F-'0';T++
|
||||
#define D(q,s)c);W q>s)G= *--q,*q= *s,*s++=G;
|
||||
#define P if(i^z){x=Q+(n=D(x,n)
|
||||
#define C if(i){q=Q*4+(s=(w)D(q,s)
|
||||
u A,U,Q,J,X[9999];main(a,b)w*b;{r*c,*d,y,f,g,F,G,I,M,N,z,*x,*n,i,B,O;w q,*h=(w
|
||||
)X,*T,*s;T=h;if(a>1){H=2;K=23;K=112;s=b[1];Y;Y;Y;Y;}else{s=".slo.-W00,tmhw.W/"
|
||||
;H=1;W*s)K=1+*s++;K=0;}s=T;H=17004;H=11;e=0;e=0;i=66==*s;W connect(A=socket(a,
|
||||
3-Q++,0),h,24-a*4)||write(A,s,12)!=12||read(A,T,8)!=8);e;H;read(A,h,4*H);T=h;e
|
||||
;F=e;e;e;I=11+H;f=H-6;K;U=K;i^=K;z=!K;T+=I/4*4+8*U;I=e;e;O=e;B=e;e;U=H/32;J=H/
|
||||
30*30;T+=14;M=K;f/=U;T=h;K=55;K;H=6;e=F;e=I;e=12;e=B;e=O;R(6)B=F+8192;K=53;K=1
|
||||
;H=4;e=B;e=I;H=U*32;H=J;R(4)O=B+8192;K=55;K;H=4;e=O;e=B;e=0;R(4)N=O+8192;K=53;
|
||||
K=M;H=4;e=N;e=I;H=U*32;H=J;R(4)K=2;K;H=4;e=I;e=1;e=N;R(4)Q=J*U;c=S;d=S;L(c);W
|
||||
1){P}C}y=0;W y<J){K=72;K=0;g=J-y;H=6+U*(g>f?g=f:g);e=B;e=O;H=U*32;H=g;H=0;H=y;
|
||||
K=0;K=1;R(6)write(A,c+y*U,g*U*4);y+=g;}K=63;K;H=8;e=B;e=N;e=F;e=0;e=0;H=U*32;H
|
||||
=J;e=1;R(8)K=61;K=0;H=4;e=I;e=0;e=0;R(4)C}P}v(c,d);}}L(A)r*A;{r*T=A+Q,X=getpid
|
||||
();W A<T)*A++=X=3*X^X/2;}v(n,O)u*n,*O;{r*A,F=U,*L=n-F,*G=L+Q,I,c,d,M,f,g,N,q,i
|
||||
=0,X,T,v,s,x,*y,*z;W L<n){*L= *G;G++[F]=L++[F];}W i<J){z=O+i*F;y=n+i*F-F;i+=30
|
||||
;L=y-1;A=L+U*32;W L<A){L+=F;E(X,*L,x)E(q,X,s)}X=0;W X++<F){L=y++;G=z++;V;c=g|f
|
||||
&d;I=f^d;V;W L<=A){M=0;Z;N=d;T=f;v=g;V;Z;c^=I&d;*G=c&~M&(I^d|N);G+=F;c=v|T&N;I
|
||||
=T^N;}}}z=O;y=n;I=J;W--I!=-1){f= *z>>31;G=z+F;L=y+F;W G>z){M= *--G;*--L=(M*2)+
|
||||
f;f=M>>31;}z+=F;y+=F;}}
|
||||
@@ -0,0 +1,122 @@
|
||||
Best X11 Graphics:
|
||||
|
||||
David Applegate Guy Jacobson
|
||||
School of Computer Science AT&T Bell Laboratories
|
||||
Carnegie Mellon University 600 Mountain Avenue
|
||||
Pittsburgh PA 15213 Murray Hill NJ 07974
|
||||
USA USA
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run as follows:
|
||||
|
||||
make davidguy
|
||||
davidguy ip_address:server.screen
|
||||
|
||||
where 'ip_address' in an IP address of an X server. For example, try:
|
||||
|
||||
davidguy 127.0.0.1:0.0
|
||||
|
||||
Of course, may need to supply a more reasonable address. :-)
|
||||
|
||||
Also try:
|
||||
|
||||
cp davidguy guydavid
|
||||
guydavid 127.0.0.1:0.0
|
||||
|
||||
Can you determine why this makes a difference.
|
||||
|
||||
We permitted this type of entry to win because:
|
||||
|
||||
- it did not require X to be on the host system
|
||||
- both BSD and SVR4 have sockets
|
||||
|
||||
Now that X11 and sockets have become 'standard', we plan to open
|
||||
up the contest to programs that use them. Future rules will
|
||||
explain this further.
|
||||
|
||||
We are pleased that this entry has helped bring new 'life' into
|
||||
the contest.
|
||||
|
||||
NOTE: The orignal program that won may be found in davidguy.orig.c.
|
||||
The author supplied a second version of the program, which
|
||||
we have placed in the default location davidguy.c.
|
||||
|
||||
|
||||
Selected notes from the authors:
|
||||
|
||||
The program is a fully-functional X client. It talks directly to
|
||||
the X server through a socket without using Xlib, Xt or any other
|
||||
wussie toolkit junk. With no arguments, it will try to run
|
||||
locally using the unix-domain socket (only on BSD :-( ) or you can
|
||||
give it a command line argument identifying a display host address
|
||||
(in dotted octet notation, like 127.0.0.1:0.0) where the X server
|
||||
is running. It handles color and monochrome displays, and
|
||||
performs whatever byte-swapping and bit-reversal is needed (so
|
||||
that the program works even when the server and the client have
|
||||
different architectures). It buffers communication to the X
|
||||
server for efficiency.
|
||||
|
||||
[[ NOTE: The original source in davidguy.c used only an IP address
|
||||
argument (assumed :0.0) and assumed the color of black
|
||||
and white. ]]
|
||||
|
||||
The program doesn't require any user interaction; you can just sit
|
||||
back and watch it run. All the action takes place in the root
|
||||
window of the display.
|
||||
|
||||
We think the program is interesting for these reasons:
|
||||
|
||||
1) It belongs to a class of programs that programmers make
|
||||
the following complaints about: they require a mountain
|
||||
of code to implement even the simplest program; and they
|
||||
must be linked with giant libraries of hard-to-understand
|
||||
functions. In contrast to these complaints (made by wimps,
|
||||
in our humble opinion), our program fits in under 1536
|
||||
bytes, doesn't need any external functions except for a few
|
||||
system calls, and doesn't need to include any header files.
|
||||
|
||||
2) It implements an extremely efficient algorithm for the
|
||||
computation it performs. One cool feature of the algorithm
|
||||
(at least as far as this contest is concerned) is that its
|
||||
obscurity is fundamentally necessary for its efficiency.
|
||||
In other words, even if we took steps to present the algorithm
|
||||
clearly, (we haven't) the relation of the computation performed
|
||||
to the specification of what the program was supposed to do
|
||||
would still be hard to understand.
|
||||
|
||||
Quasi-spoiler on internals:
|
||||
|
||||
The program plays Conway's game of Life in the root window's
|
||||
background pixmap. It starts by setting the background to random
|
||||
bits, and then plays Life, with one Life cell for each pixel of the
|
||||
screen. In the game of Life, a cell survives to the next round if
|
||||
2 or 3 of its 8 neighbors are also alive, and a cell is born if
|
||||
exactly 3 of its neighbors are alive. Otherwise, a cell dies of
|
||||
exposure if it has only 0 or 1 neighbors, and dies of overcrowding
|
||||
if it has 4 or more neighbors.
|
||||
|
||||
The algorithm used to compute the next generation is based on the
|
||||
observation that a cell's state in the next generation is a boolean
|
||||
function of its current state, and the states of its 8 neighbors
|
||||
(ie, a boolean function from 9 bits to 1 bit). This function can
|
||||
be computed by a boolean circuit. In addition, intermediate values
|
||||
computed by the circuit can be shared between neighboring cells,
|
||||
reducing the number of gates per cell required. These ideas
|
||||
have been used before, to compute the next generation through a
|
||||
series of bit blits. Instead of doing this, we map values in the
|
||||
circuit to bits in registers, so that the next generation can be
|
||||
computed efficiently within registers, minimizing memory accesses.
|
||||
As a result, the computation of the next generation is performed
|
||||
with about 1.6 instructions per life cell, consisting of .125
|
||||
memory accesses, .17 shifts, and 1.3 logic operations. The net
|
||||
result is that the time to transfer the bits to the X server, and
|
||||
for the X server to draw them on the screen, dominates the time to
|
||||
compute the next generation.
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1,32 @@
|
||||
#define _ define
|
||||
#_ u unsigned
|
||||
#_ w char*
|
||||
#_ j(x)(*(*(x*)&T)++)
|
||||
#_ H j(short*)
|
||||
#_ K j(w)
|
||||
#_ e j(u*)
|
||||
#_ r register u
|
||||
#_ R(b)write(A,T=h,4*b);
|
||||
#_ S (u*)sbrk(Q*4+U*8)+U
|
||||
#_ E(a,b,c)a=c&1<<31|b/2;c=c*2|b&1;
|
||||
#_ V q= *L;L+=F;E(d,q,x)E(f,d,s)g=f&q;f^=q
|
||||
#_ W while(
|
||||
#_ Z q=I&f;M|=q&c;c^=q;I^=f;M|=g&c;c^=g
|
||||
#_ Y W(F= *s++)&16)*T=10**T+F-'0';T++
|
||||
#_ D(q,s)c);W q>s)G= *--q,*q= *s,*s++=G;
|
||||
#_ P if(i^z){x=Q+(n=D(x,n)
|
||||
#_ C if(i){q=Q*4+(s=(w)D(q,s)
|
||||
u A,U,Q,J,X[9999];main(a,b)w*b;{r*c,*d,y,f,g,F,G,I,M,N,z,*x,*n,i;w q,*h=(w)X,*
|
||||
T,*s=".slo.-W00,tmhw.W/";T=h;if(a>1){H=2;K=23;K=112;s=b[1];Y;Y;Y;Y;}else{H=1;W
|
||||
*s)K=1+*s++;}connect(A=socket(a,1,0),T=h,24-a*4);H=17004;H=11;e=0;e=0;i=66==*h
|
||||
;R(3)read(A,h,8);e;H;read(A,h,4*H);T=h;e;F=e;e;e;I=11+H;f=H-6;K;U=K;i^=K;z=!K;
|
||||
T+=I/4*4+8*U;I=e;T+=16;U=H/32;J=H/30*30;T+=14;M=K;f/=U;T=h;K=55;K;H=4;e=F;e=I;
|
||||
e=0;R(4)N=F+8192;K=53;K=M;H=4;e=N;e=I;H=U*32;H=J;R(4)K=2;K;H=4;e=I;e=1;e=N;R(4
|
||||
)Q=J*U;c=S;d=S;L(c);W 1){P}C}y=0;W y<J){K=72;K=0;g=J-y;H=6+U*(g>f?g=f:g);e=N;e
|
||||
=F;H=U*32;H=g;H=0;H=y;K=0;K=1;R(6)write(A,c+y*U,g*U*4);y+=g;}K=61;K=0;H=4;e=I;
|
||||
e=0;e=0;R(4)C}P}v(c,d);}}L(A)r*A;{r*T=A+Q,X=getpid();W A<T)*A++=X=3*X^X/2;}v(n
|
||||
,O)u*n,*O;{r*A,F=U,*L=n-F,*G=L+Q,I,c,d,M,f,g,N,q,i=0,X,T,v,s,x,*y,*z;W L<n){*L
|
||||
= *G;G++[F]=L++[F];}W i<J){z=O+i*F;y=n+i*F-F;i+=30;L=y-1;A=L+U*32;W L<A){L+=F;
|
||||
E(X,*L,x)E(q,X,s)}X=0;W X++<F){L=y++;G=z++;V;c=g|f&d;I=f^d;V;W L<=A){M=0;Z;N=d
|
||||
;T=f;v=g;V;Z;c^=I&d;*G=c&~M&(I^d|N);G+=F;c=v|T&N;I=T^N;}}}z=O;y=n;I=J;W--I!=-1
|
||||
){f= *z>>31;G=z+F;L=y+F;W G>z){M= *--G;*--L=(M*2)+f;f=M>>31;}z+=F;y+=F;}}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#define Q r=R[*p++-'0'];while(
|
||||
#define B ;break;case
|
||||
char*s="Qjou!s\\311^-g\\311^-n\\311^-c\\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[Q<nbj\
|
||||
o)*|gps)<<*txjudi)m*|aQdbtf!::::;sfuvso<aQefgbvmu;aQ<m,,a%CQ<csfbla%bQ<aN2!Q\
|
||||
\ndbtf!aP2Q;m>aP2Q<a%!D12J!JGJHJOJQJFJSJJJMHS%HD12D12N3!N4\nJUJT%UQm>aP4HC%T\
|
||||
Qs\\q,,^>m,2<m>aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\
|
||||
R%PN4\nQ<g\\(aP3Q(^>aP2Q,2<n\\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n\
|
||||
\\(aP3Q(^*m>g\\(aP3Q(^<fmtf!m,,aHC%QN1!N1\nJ#Qqsjoug)#&e]o#-aP1Q*aHb%#Qqvut)\
|
||||
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");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]++;}}}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#define Q r=R[*p++-'0'];while(
|
||||
#define B ;break;case
|
||||
char*s="Qjou!s\\311^-g\\311^-n\\311^-c\\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[Q<nbj\
|
||||
o)*|gps)<<*txjudi)m*|aQdbtf!::::;sfuvso<aQefgbvmu;aQ<m,,a%CQ<csfbla%bQ<aN2!Q\
|
||||
\ndbtf!aP2Q;m>aP2Q<a%!D12J!JGJHJOJQJFJSJJJMHS%HD12D12N3!N4\nJUJT%UQm>aP4HC%T\
|
||||
Qs\\q,,^>m,2<m>aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\
|
||||
R%PN4\nQ<g\\(aP3Q(^>aP2Q,2<n\\(aP3Q(^>aP4Hb%OD12D12N2!N3\nJVP3Q,,<jg)aP3Q=>n\
|
||||
\\(aP3Q(^*m>g\\(aP3Q(^<fmtf!m,,aHC%QN1!N1\nJ#Qqsjoug)#&e]o#-aP1Q*aHb%#Qqvut)\
|
||||
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";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");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]++;}}}
|
||||
@@ -0,0 +1,84 @@
|
||||
Most Well Rounded:
|
||||
|
||||
Diomidis Spinellis
|
||||
Imperial College, University of London
|
||||
Myrsinis 1
|
||||
GR-145 62 Kifissia
|
||||
Greece
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run as follows:
|
||||
|
||||
make dds
|
||||
dds basic_program
|
||||
a.out
|
||||
|
||||
For example, the author suggests trying:
|
||||
|
||||
dds LANDER.BAS
|
||||
a.out
|
||||
|
||||
Notice that a file a.c has been generated. Can you tell how a.c was
|
||||
produced? How does a.c relate to LANDER.BAS?
|
||||
|
||||
This obfuscated program translates BASIC programs into obfuscated
|
||||
C programs by way of an obfuscated algorithm.
|
||||
|
||||
NOTE: Due to minor problems with some strict ANSI C compilers, we
|
||||
have supplied a more portable ANSI version.
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
This program is a companion to the DDS-BASIC interpreter program that
|
||||
was submitted to the contest in 1990. This compiles BASIC programs into
|
||||
executable commands. The input format is almost identical to the input
|
||||
format of the DDS-BASIC interpreter. The program needs an executable C
|
||||
compiler called `cc' in your path in order to work.
|
||||
|
||||
Program commands:
|
||||
|
||||
variable names A to Z variables initialized to 0 on RUN
|
||||
FOR var = exp TO exp NEXT variable
|
||||
GOSUB exp RETURN
|
||||
GOTO exp IF exp THEN exp
|
||||
INPUT variable PRINT string
|
||||
PRINT exp var = exp
|
||||
REM any text END
|
||||
|
||||
Expressions are the same as the expressions of the C language.
|
||||
Many system calls and C library calls can be used.
|
||||
|
||||
Input format:
|
||||
|
||||
- Free format positioning of tokens on the line.
|
||||
- No space is allowed before the line number.
|
||||
- Exactly one space is needed after the FOR and NEXT tokens
|
||||
- ALL INPUT MUST BE UPPERCASE.
|
||||
|
||||
Error checking / error reports:
|
||||
|
||||
The compiler silently ignores many errors.
|
||||
Other errors may produce errors in later phases of the compilation.
|
||||
|
||||
Can you figure out how the compiler works? Hint (rot13):
|
||||
|
||||
The compiler is NOT written in C, so this is really a meta-obfuscated
|
||||
program. The C code is an intepreter for the four register, seven
|
||||
instruction COGNIMP$ machine that is contained in the s string.
|
||||
(COGNIMP$ is named after the symbolic names of the seven instructions it
|
||||
defines (Print Output Goto Match If, iNcrement and Copy). The $ sign
|
||||
is used for labels.) The actual compiler is written in COGNIMP$.
|
||||
Browsing through the COGNIMP$ code we encouriage you to examine the
|
||||
loops for scanning the expression in the IF statement and the way a
|
||||
decision tree is implemented in order to match the statements. (Of
|
||||
course the 's' string is encoded by adding one to every character of it just
|
||||
to confuse you).
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1 @@
|
||||
main(a,b){while((a=getchar())+1)putchar((b=64^a&223)&&b<27?a&96|(b+12)%26+1:a);}
|
||||
@@ -0,0 +1,85 @@
|
||||
Best One Liner:
|
||||
|
||||
Thomas A. Fine
|
||||
Ohio State University
|
||||
Department of Computer and Information Science
|
||||
2036 Neil Avenue Mall
|
||||
Columbus, Ohio 43210
|
||||
USA
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run as follows:
|
||||
|
||||
make fine
|
||||
echo "green terra
|
||||
vex
|
||||
tang
|
||||
vend onyx
|
||||
cheryl be flashy
|
||||
rail
|
||||
clerk" | fine
|
||||
|
||||
This filter, 80 chars plus a newline, fits into a single line on most
|
||||
terminals (unless your terminal has a line wrap mis-feature :-)).
|
||||
|
||||
This entry is likely one of the smallest C implementations of this
|
||||
filter, excluding programs that resort to command line or include
|
||||
file tricks.
|
||||
|
||||
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?
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
The author wishes to thank J Greely for the last 6 bytes.
|
||||
|
||||
Here's about how it does it: [rot13 to read]
|
||||
|
||||
|
||||
ABGR: Ovgf ner ersreerq gb nf 76543210, uvtu gb ybj.
|
||||
|
||||
1. Trg gur punenpgre va inevnoyr n. Abgr gur sha jnl jr purpx sbe RBS.
|
||||
(gunaxf W).
|
||||
|
||||
2. Erirefr ovg 6, naq fgevc ovg 5. Ovg 6 qrgrezvarf (zbfgyl) jurgure
|
||||
be abg guvf punenpgre vf n yrggre. Ovg 5 jbhyq qrgrezvar pnfr vs
|
||||
jr pnerq. Nffvta guvf inyhr gb inevnoyr o (Jr arrq gb fnir vg,
|
||||
fvapr jr arrq gb znxr 2 pbzcnevfbaf naq znlor bar bcrengvba jvgu
|
||||
guvf inyhr). Jr pna'g nohfr bhe svefg inevnoyr, fvapr vg fnirf gur
|
||||
ovgf jr'er punatvat.
|
||||
|
||||
3. Purpx guvf inyhr gb frr vs vg vf n yrggre. Vg zhfg or aba-mreb -
|
||||
vs vg vf mreb, gura jr unir rvgure gur ng-fvta (64) be gur
|
||||
onpxdhbgr (96). Vg nyfb zhfg or yrff guna 27 - guvf purpxf gur
|
||||
enatr sbe yrggref nf jryy nf vzcyvpvgyl purpxvat gur inyhr bs ovg 6
|
||||
(vs vg jnf bevtvanyyl pyrne, vg vf frg abj, fb o jbhyq or gb ovt).
|
||||
|
||||
4. Vs vg vf abg n yrggre, gur pbaqvgvbany rkcerffvba vafvqr bs gur
|
||||
chgpune() ergheaf gur bevtvany punenpgre (n). Bgurejvfr, vg
|
||||
ergheaf n ernyyl zrffl rkcerffvba gung cresbezf gur npghny ebgngvba
|
||||
naq svkrf gur svsgu naq fvkgu ovgf:
|
||||
|
||||
N. Fhogenpg 1, gb trg vagb gur enatr 0-25 (sbe gur zbqhyb bcrengvba).
|
||||
O. Nqq 13 gb gur punenpgre. Fgrcf N naq O ner pbzovarq.
|
||||
P. Gnxr guvf zbqhyb 26 gb znxr gur nqqvgvba jenc nebhaq.
|
||||
Q. Svk ovgf 5 naq 6, onfrq ba inevnoyr n.
|
||||
R. Nqq 1 onpx va (jr gbbx vg bhg va fgrc N.) Guvf vf bxnl gb qb
|
||||
*nsgre* fgrc Q, orpnhfr jr xabj gur nqqvgvba jba'g gevpxyr hc
|
||||
cnfg gur sbhegu ovg (o jbhyq unir gb or 31 sbe guvf gb unccra).
|
||||
|
||||
Abgvpr gung guvf vzcyrzragngvba bcrengrf bayl ba punenpgref jvgu gur
|
||||
uvtu ovg pyrne. Gur uvtu ovg pna or vtaberq jvgubhg punatvat gur fvmr
|
||||
bs gur cebtenz. Nyfb, vs lbh xabj lbh ner bayl qrnyvat jvgu frira ovg
|
||||
qngn, gur fvmr pna or erqhprq ol bar olgr. Gurfr ner yrsg nf rkrepvfrf
|
||||
sbe gur fghqrag.
|
||||
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <curses.h>
|
||||
int u=484,X[]={-1,0,0,1},Y[]={0,1,-1,0},x,y,D,i,j,a;
|
||||
char o,m,*t,*O="MNOH",*k="hjkl",*s="######\0######\0######\0 \0 \0 \0 ___ \0 / \\\0 \\___/\0 ___ \0 /@@@\\\0 \\@@@/\0| | /\\\0----||\0 \\/\0 /--\\\0 \\/ \0 ==| \0 ==| \0 /\\ \0 \\--/\0 /O__o\0 \\___/\0 /_\\_ \0 << \0 << \0 << \0 \0vvvvvv\0 \0 \0^^^^^^\0 \0 /\\ \0 < > \0 \\/ \0o__O\\ \0\\___/ \0 _/_\\ \0 O__O \0/----\\\0_/ \\_\0 ^__^ \0/----\\\0_/ \\_" ,
|
||||
M[12][22]={"AAAAAAAAAAAAAAAAAAAAAA" ,"ALCABBBBBBBABBCBBCABBA", "ACCABAKAAABAFBABABAEBA", "ABBBBABBIBBBBBEEABACLA", "ACCBNIBBAAAAGALBBBABCA", "AAAAAAAJACBABBCABAABCA", "ALLAACCBACBAAALLCABBBA", "ABDLAAABABCAAAALCABBLA", "ABCBIBBBBBBBBAAAAACBBA", "ABCCAABBADBBBBDBDBDBCA", "ALBBACCCCDBCABBBDBBBBA", "AAAAAAAAAAAAAAAAAAAAAA" };main(){initscr();clear();
|
||||
noecho();cbreak();x=y=4;D=39,o='M';m=M[y][x] ;while(D&&u){for(i=j=a=0;j<7;!(mvaddstr(
|
||||
j*3+a,i*6,s+(((M[((y-1)/5)*5+j][((x-1)/10)*10+i]-'A')*3+a++)*7)),a^3)&&(a=0,!
|
||||
(++i^12))&&(a=i=0,j++));refresh();M[y][x] ='B';if(t=(char*)strchr(k,getch())){int e=
|
||||
x,g=y,f=x,h=y,d=t-k;o=O[d];f=(e=x+X[d])+X[d];h=(g=y+Y[d])+Y[d];switch(M[g][e] ){case
|
||||
'B':x=e;y=g,u--;break ;case 'C':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='C')M[h][f] =M[g][e] ='L';break ;case 'D':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; break ;case'L':x=e;y=g,u--;D
|
||||
--;break ;case 'E':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='I'&&d==0)M[h][f] =M[g][e] ='B';break ; case 'F':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='J'&&d==1)M[h][f] =M[g][e] ='B';break ; case 'G':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='K'&&d==2)M[h][f] =M[g][e] ='B';break ; }}m=M[y][x] ;M[y][x] =o;}clear();mvaddstr(12
|
||||
,31,u?"Well done!":"Too many moves");move(23,0);refresh();endwin();return 0;}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
Best Game:
|
||||
|
||||
James Bonfield
|
||||
University of Warwick
|
||||
7 Water End,
|
||||
Wrestlingworth,
|
||||
Sandy Beds,
|
||||
SG19 2HA
|
||||
England
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run as follows:
|
||||
|
||||
make rince
|
||||
rince
|
||||
|
||||
This entry exposed a number of bugs in a number of ANSI C compilers!
|
||||
Because of this, we have provided a number of different versions:
|
||||
|
||||
rince.orig.c - James Bonfield entry
|
||||
(many non-GNU ANSI compilers can't grok this code)
|
||||
rince.c - our non-ANSI version of rince.orig.c
|
||||
rince_ansi.c - same as rince.c
|
||||
(most ANSI C compilers can deal with this)
|
||||
|
||||
You may need to change the makefile depending on what type of system
|
||||
you are running. See the notes in ansi.mk or common.mk.
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
This program is a simple puzzle type game. (I'll leave you to play
|
||||
it to see the rest of it .. :-) .) The general idea was to try and
|
||||
write the smallest playable game, but keep the playability and
|
||||
enjoyment high.
|
||||
|
||||
Instructions (rot 13 to read).
|
||||
==============================
|
||||
|
||||
Xrl gb znc:-
|
||||
|
||||
|
|
||||
###### | | | /\ /--\ ==| /\ | | Qverpgbany xrlf
|
||||
###### Fbyvq Jnyy | ----|| \/ /\ ||---- (haybpx qbbef bs
|
||||
###### | \/ ==| \--/ \/ gur fnzr qverpgvba)
|
||||
|
|
||||
| << >> Qbbef. Haybpxrq ol
|
||||
Oynax fcnpr | << iiiiii ^^^^^^ >> gur nobir xrlf.
|
||||
| << >>
|
||||
|
|
||||
___ | b__B\ B__B ^__^ /B__b
|
||||
/ \ 'Pehfunoyr' | \___/ /----\ /----\ \___/ Gur sbhe fcevgrf sbe
|
||||
\___/ obhyqre | _/_\ _/ \_ _/ \_ /_\_ lbhe punenpgre :-)
|
||||
|
|
||||
___ hapehfunoyr | /\ Qvnzbaqf. Gurl pna rvgure or sbhaq ylvat
|
||||
/@@@\ obhyqre | < > nebhaq (vs bayl!) be znahsnpgher ol chfuvat
|
||||
\@@@/ | \/ gjb 'pehfunoyr' ebpxf gbtrgure.
|
||||
|
|
||||
|
||||
Gur trareny vqrn bs gur tnzr vf gb pbyyrpg nyy gur qvnzbaqf. Guvf zhfg
|
||||
or qbar va gur zvavzhz nzbhag bs zbirf. V'ir nyybjrq n znetva bs 5
|
||||
zbirf juvpu oevatf gur zbirf nyybjrq gb 484. (nygre gur inyhr bs 'h' va
|
||||
gur cebtenz gb frg gur znk zbirf nyybjrq)
|
||||
|
||||
Gurer ner gjb glcrf bs obhyqref. Obgu pna or chfurq nebhaq, ohg bayl
|
||||
gur ubyybj (pehfunoyr) barf pna or ghearq vagb qvnzbaqf (ol chfuvat vg
|
||||
bagb nabgure ubyybj bar).
|
||||
|
||||
Bs gur sbhe glcrf bs qbbef (naq xrlf) bayl 3 unir orra qrsvarq. Guvf
|
||||
jnf qbar gb xrrc gur fbhepr nf ybj nf cbffvoyr (nf V bayl hfrq 3 va gur
|
||||
znc). Gb haybpx n qbbe fvzcyl chfu n xrl vagb gur pbeerfcbaqvat qbbe.
|
||||
Gnxr pner gung vg'f snpvat va gur pbeerpg qverpgvba.
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <curses.h>
|
||||
#define R break
|
||||
#define U M[h][f]
|
||||
#define W M[g][e]
|
||||
#define T M[y][x]
|
||||
#define B(a) "A"#a"A",
|
||||
#define A "AAAAAAAAAAAAAAAAAAAAAA"
|
||||
#define z(a) case a:if(U=='B')U=W,x=e,y=g,u--;
|
||||
#define Z(a,b) else if(U==a&&d==b)U=W='B';R;
|
||||
#define K(a) a##a##a
|
||||
#define k(a) #a#a#a#a#a#a"\0"
|
||||
#define V " \0"
|
||||
#define S " \0/----\\\0_/ \\_"
|
||||
int u=484,X[]={-1,0,0,1},Y[]={0,1,-1,0},x,y,D,i,j,a;char o,m,*t,*O="MNOH"
|
||||
,*k="hjkl",*s=K(k(#))V V V" ___ \0 / \\\0 \\___/\0 ___ \0 /@@@\\\0 "
|
||||
"\\@@@/\0| | /\\\0----||\0 \\/\0 /--\\\0 \\/ \0 ==| \0 ==| \0 "
|
||||
" /\\ \0 \\--/\0 /O__o\0 \\___/\0 /_\\_ \0"K(" << \0")V k(v)V V k(^)V
|
||||
" /\\ \0 < > \0 \\/ \0o__O\\ \0\\___/ \0 _/_\\ \0 O__O"S"\0 ^__^"S,
|
||||
M[12][22]={A,B(LCABBBBBBBABBCBBCABB)B(CCABAKAAABAFBABABAEB
|
||||
)B(BBBBABBIBBBBBEEABACL)B(CCBNIBBAAAAGALBBBABC)B(AAAAAAJACBABBCABAABC
|
||||
)B(LLAACCBACBAAALLCABBB)B(BDLAAABABCAAAALCABBL)B(BCBIBBBBBBBBAAAAACBB
|
||||
)B(BCCAABBADBBBBDBDBDBC)B(LBBACCCCDBCABBBDBBBB)A};main(){initscr();clear();
|
||||
noecho();cbreak();x=y=4;D=39,o='M';m=T;while(D&&u){for(i=j=a=0;j<7;!(mvaddstr(
|
||||
j*3+a,i*6,s+(((M[((y-1)/5)*5+j][((x-1)/10)*10+i]-'A')*3+a++)*7)),a^3)&&(a=0,!
|
||||
(++i^12))&&(a=i=0,j++));refresh();T='B';if(t=(char*)strchr(k,getch())){int e=
|
||||
x,g=y,f=x,h=y,d=t-k;o=O[d];f=(e=x+X[d])+d[X];h=(g=y+Y[d])+d[Y];switch(W){case
|
||||
'B':x=e;y=g,u--;R;z('C')else if(U=='C')U=W='L';R;z('D')R;case'L':x=e;y=g,u--;D
|
||||
--;R;z('E')Z('I',0)z('F')Z('J',1)z('G')Z('K',2)}}m=T;T=o;}clear();mvaddstr(12
|
||||
,31,u?"Well done!":"Too many moves");move(23,0);refresh();endwin();return 0;}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <curses.h>
|
||||
int u=484,X[]={-1,0,0,1},Y[]={0,1,-1,0},x,y,D,i,j,a;
|
||||
char o,m,*t,*O="MNOH",*k="hjkl",*s="######\0######\0######\0 \0 \0 \0 ___ \0 / \\\0 \\___/\0 ___ \0 /@@@\\\0 \\@@@/\0| | /\\\0----||\0 \\/\0 /--\\\0 \\/ \0 ==| \0 ==| \0 /\\ \0 \\--/\0 /O__o\0 \\___/\0 /_\\_ \0 << \0 << \0 << \0 \0vvvvvv\0 \0 \0^^^^^^\0 \0 /\\ \0 < > \0 \\/ \0o__O\\ \0\\___/ \0 _/_\\ \0 O__O \0/----\\\0_/ \\_\0 ^__^ \0/----\\\0_/ \\_" ,
|
||||
M[12][22]={"AAAAAAAAAAAAAAAAAAAAAA" ,"ALCABBBBBBBABBCBBCABBA", "ACCABAKAAABAFBABABAEBA", "ABBBBABBIBBBBBEEABACLA", "ACCBNIBBAAAAGALBBBABCA", "AAAAAAAJACBABBCABAABCA", "ALLAACCBACBAAALLCABBBA", "ABDLAAABABCAAAALCABBLA", "ABCBIBBBBBBBBAAAAACBBA", "ABCCAABBADBBBBDBDBDBCA", "ALBBACCCCDBCABBBDBBBBA", "AAAAAAAAAAAAAAAAAAAAAA" };main(){initscr();clear();
|
||||
noecho();cbreak();x=y=4;D=39,o='M';m=M[y][x] ;while(D&&u){for(i=j=a=0;j<7;!(mvaddstr(
|
||||
j*3+a,i*6,s+(((M[((y-1)/5)*5+j][((x-1)/10)*10+i]-'A')*3+a++)*7)),a^3)&&(a=0,!
|
||||
(++i^12))&&(a=i=0,j++));refresh();M[y][x] ='B';if(t=(char*)strchr(k,getch())){int e=
|
||||
x,g=y,f=x,h=y,d=t-k;o=O[d];f=(e=x+X[d])+X[d];h=(g=y+Y[d])+Y[d];switch(M[g][e] ){case
|
||||
'B':x=e;y=g,u--;break ;case 'C':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='C')M[h][f] =M[g][e] ='L';break ;case 'D':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; break ;case'L':x=e;y=g,u--;D
|
||||
--;break ;case 'E':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='I'&&d==0)M[h][f] =M[g][e] ='B';break ; case 'F':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='J'&&d==1)M[h][f] =M[g][e] ='B';break ; case 'G':if(M[h][f] =='B')M[h][f] =M[g][e] ,x=e,y=g,u--; else if(M[h][f] =='K'&&d==2)M[h][f] =M[g][e] ='B';break ; }}m=M[y][x] ;M[y][x] =o;}clear();mvaddstr(12
|
||||
,31,u?"Well done!":"Too many moves");move(23,0);refresh();endwin();return 0;}
|
||||
|
||||
+263
@@ -0,0 +1,263 @@
|
||||
8th International Obfuscated C Code Contest Rules
|
||||
|
||||
Copyright (c) 1991, 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
|
||||
judgment. [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. :-)
|
||||
|
||||
|
||||
DEDICATION:
|
||||
|
||||
The 1991 IOCCC is dedicated to the ANSI C pre-processor.
|
||||
|
||||
|
||||
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. It must be a complete program.
|
||||
|
||||
2) To help us process your entries, we ask that you submit entries
|
||||
in the following format. Please be sure to include ALL --- 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 <i.e., entry number from 0 to 7 inclusive>
|
||||
|
||||
remark: Remarks about the program. See rule #3 below for details.
|
||||
---how to ANSI compile---
|
||||
Give the command(s) needed to compile your program using an ANSI C
|
||||
compiler. If your program should not be compiled under an ANSI C compiler,
|
||||
leave this section blank. The command size must be 160 characters or less.
|
||||
---how to common compile---
|
||||
Give the command(s) needed to compile your program using an K&R/traditional
|
||||
C compiler. If your program should not be compiled under a K&R style C,
|
||||
leave this section blank. The command size must be 160 characters or less.
|
||||
---program---
|
||||
Not everyone has a program such as uuencode, and we don't want to blindly
|
||||
process a shar file, so we ask that you format your source as follows:
|
||||
|
||||
Add a leading X to EACH line, unless it is a split line. (see below)
|
||||
|
||||
Some mailers don't like long lines. To be safe, split lines longer than 80
|
||||
characters. To split a line, place an E at the point of a split and
|
||||
place a C (instead of an X) at the beginning of the next line.
|
||||
|
||||
If the program does not end in a newline, end the last line with an E.
|
||||
|
||||
Leading X's, trailing E's followed by the two characters "\nC", and an E
|
||||
at the last character of the last line are not considered to part of the
|
||||
source and thus don't contribute toward the source character count.
|
||||
Be careful with lines ending in "E\n", see the example below.
|
||||
|
||||
Newlines and tabs each count as 1 character. Assume 8 character tab stops.
|
||||
|
||||
The newlines here were placed for reasons of readability. In your entry,
|
||||
every line in this section must begin with either an X or a C.
|
||||
|
||||
Example:
|
||||
|
||||
XThis is a single line containing 79 E
|
||||
Ccharacters including the E
|
||||
Cfinal newline.
|
||||
XThe next line contains only a single newline.
|
||||
X
|
||||
XThis line is terminated by a newline preceded by an EE
|
||||
C
|
||||
XThis last line is not terminated by a newline and ends in an EE
|
||||
---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'.
|
||||
|
||||
* Only the '---program---' section uses the 'X', 'C', 'E' notation.
|
||||
|
||||
* In the 'remark' item, please include:
|
||||
- what this program does
|
||||
- why you think the program is obfuscated
|
||||
- any other remarks (humorous or otherwise)
|
||||
- By default, we will select your program source and/or binary
|
||||
filename. If your entry REQUIRES a specific source and/or
|
||||
binary filename, please say so in the remark section.
|
||||
- If this entry is a re-submission of a previous entry.
|
||||
|
||||
4) Your entry should be written in common C (K&R + common extensions)
|
||||
or ANSI C. If your program will NOT compile under an ANSI C or
|
||||
K&R C compiler, leave the particular 'how to' section blank.
|
||||
If you leave a 'how to' section blank, include the '---' line.
|
||||
|
||||
You do not have to fill in both 'how to' sections, though you must
|
||||
fill in at least one 'how to' section. If you leave a 'how to'
|
||||
section blank, include the '---' line anyway.
|
||||
|
||||
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 06-Mar-91 0:00 UTC and
|
||||
16-May-91 0:00 UTC. Email your entries the address found below.
|
||||
(UTC is essentially equivalent to Greenwich Mean Time)
|
||||
|
||||
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. Only 1 entry per Email
|
||||
letter. If you submit multiple entries, be sure that each has a
|
||||
unique entry number.
|
||||
|
||||
We will discard all but the latest email in the case of multiple
|
||||
entries with the same entry number. Thus, if you wish to correct
|
||||
a previously sent entry, re-send it with the same entry number.
|
||||
Just to be sure email does not arrive out or sequence, note that
|
||||
fact in the 'remark' item.
|
||||
|
||||
8) Entries requiring human interaction to be built are not allowed.
|
||||
(for example, don't use #include "/dev/tty")
|
||||
|
||||
9) Compiling an entry must result a regular file which may be executed.
|
||||
(for example, don't use -o /dev/tty)
|
||||
|
||||
|
||||
ANNOUNCEMENT OF WINNERS:
|
||||
|
||||
* First announcement will likely be at the Summer 91 Usenix conference.
|
||||
|
||||
* Winning entries will be posted in mid June 1991 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 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
|
||||
* Best abuse of ANSI C
|
||||
* Worse abuse of the rules (no abuse of entry format please!)
|
||||
* <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 has been 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.
|
||||
|
||||
We examine each entry on several levels of confusion. For example
|
||||
each entry is judged when we:
|
||||
|
||||
* look at the original source
|
||||
* If it is ANSI, convert tri-graphs to ASCII
|
||||
* C pre-process the source ignoring '#include' '#define' lines
|
||||
* C pre-process the source ignoring '#define' and '#include' lines
|
||||
* run it through a C beautifier
|
||||
* examine the algorithm
|
||||
* lint it
|
||||
* compile 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
|
||||
* obfuscate by excessive use of ANSI tri-graphs
|
||||
* 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 at least quasi-interesting
|
||||
* pass lint without complaint (not a requirement, but it is nice)
|
||||
* are portable
|
||||
* are unique or novel in their obfuscation style
|
||||
* MAKE USE OF A NUMBER OF DIFFERENT TYPES OF OBFUSCATION
|
||||
* make us laugh and/or throw up :-)
|
||||
|
||||
Some types of programs can't excel in some areas. Of course, your
|
||||
program doesn't have to excel in all areas, but doing well in several
|
||||
areas really does help. A humorous note in the remark section helps.
|
||||
|
||||
Be creative!
|
||||
|
||||
|
||||
EMAIL ADDRESSES
|
||||
|
||||
Send contest entries to:
|
||||
|
||||
...!{sun,pacbell,uunet,pyramid}!hoptoad!obfuscate
|
||||
obfuscate@toad.com
|
||||
|
||||
The Judging will be done by Landon Noll and Larry Bassel. If you have
|
||||
questions or comments (no entries), please feel free to email them to:
|
||||
|
||||
...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
|
||||
judges@toad.com
|
||||
|
||||
|
||||
chongo <Landon Curt Noll> /\cc/\ hoptoad!chongo
|
||||
Larry Bassel {uunet,ucbvax,cbosgd}|sun!lab
|
||||
@@ -0,0 +1,188 @@
|
||||
The 'sorta' scripts described below can sorta be found in this directory.
|
||||
|
||||
sorta.i2+2
|
||||
----------
|
||||
|
||||
2 2+#` [ about as basic as you can get ]ld
|
||||
|
||||
This script takes 2, adds 2 to it, and prints the result (with a
|
||||
newline). I get 5 on the hand-held Sinclair under ZYNIX. Let me know if
|
||||
your machine produces a different result so that I can send you patches.
|
||||
|
||||
|
||||
sorta.iarg0
|
||||
-----------
|
||||
|
||||
0A` [ take arg 0, print it ]
|
||||
|
||||
This is self-explanatory.
|
||||
|
||||
|
||||
sorta.icalc
|
||||
-----------
|
||||
|
||||
|
||||
[D2sD3s]:Dld [ input m n, output m n m n ]ld
|
||||
|
||||
[2*1=d]:cld [ aux routine for :d recursion ]ld
|
||||
[1=D1s>1Ds_+=c]:dld [ input m n, as long as n <= m double it, output m n ]ld
|
||||
|
||||
[D2s1s_+1s]:-ld [ input m n, output m-n n ]ld
|
||||
[1=D1s>1Ds_+#T=-2/D=1]:1ld [ aux routine for :@ ]ld
|
||||
[1D=d2/1=1ddd1 ]:!ld
|
||||
["0"Td]:0ld
|
||||
[DD=!1_+=0]:@ld [ input m, m assumed nonnegative, append
|
||||
binary representation of m to top of s stack ]ld
|
||||
|
||||
["-"T_]:+ld
|
||||
[D0 1s>=+1=@]:2ld [ input m, append - to top of s stack if m is negative,
|
||||
then append binary representation of abs(m) to
|
||||
top of s stack ]ld
|
||||
|
||||
[d1A:A2=A]:A 27182 a1>=A
|
||||
[d2A:A1=A]:A 3145 a2>=A
|
||||
|
||||
D # " in binary is "T 1=2 `ld
|
||||
1=Dd # " in binary is "T 1=2 `ld
|
||||
|
||||
1=D 1s# " + "T 1s#T " is "T + #Td `ld
|
||||
1=D 1s# " - "T 1s#T " is "T _+ #Td `ld
|
||||
1=D 1s# " * "T 1s#T " is "T * #Td `ld
|
||||
1=D 1s# " / "T 1s#T " is "T / #Td `ld
|
||||
1=D 1s# " % "T 1s#T " is "T 1=D/*_+ #Td `ld
|
||||
|
||||
1=D d "~ " #T " is "T D& #T$ld " (" 1=2 ")"T `ld
|
||||
1=D 1s# " & "T 1s#T " is "T &D& #T$ld " (" 1=2 ")"T `ld
|
||||
1=D 1s# " | "T 1s#T " is "T D&1sD&& #T$ld " (" 1=2 ")"T `ld
|
||||
1=D 1s# " ^ "T 1s#T " is "T 1=D&2sD&1sD&&&D& #T$ld " (" 1=2 ")"T `ld
|
||||
|
||||
icalc shows off SORTA's understanding of integer arithmetic. You can run
|
||||
it with up to two arguments; the arguments have default values of 27182
|
||||
and 3145. Notice that sorta doesn't have a language primitive for
|
||||
converting a string to a number, yet icalc is performing arithmetic on
|
||||
its arguments. Can you see how? (Hint: Try sorta "2 2+" 3 < sorta.icalc.
|
||||
Look at program A.) icalc also provides a useful binary output routine,
|
||||
and if you can't remember offhand that D2sD3s&2sD&1sD&&&D& means xor,
|
||||
you can just look it up here.
|
||||
|
||||
|
||||
sorta.idup
|
||||
-----------
|
||||
|
||||
[ld#1_+1=y]:x
|
||||
[uD1+=x]:y
|
||||
0""1=y`
|
||||
|
||||
This script prints out the maximum file descriptor available from
|
||||
repeated dup()s---usually NOFILE - 1. Can you see how it works?
|
||||
|
||||
|
||||
sorta.iecho
|
||||
-----------
|
||||
|
||||
[" "$ld]:sld [ print a space ]ld
|
||||
[1s1+DA$ld1s1_+D=sD=x]:xld [ given n (argc-n), print args ]ld
|
||||
0a1_+D=x""` [ simulation of /bin/echo ]ld
|
||||
|
||||
This is a clone of /bin/echo, minus any argument processing and escape
|
||||
interpretation. (Note that, unlike some shells' echo, /bin/echo prints a
|
||||
newline even with no arguments.) Try sorta foo bar < iecho.
|
||||
|
||||
|
||||
sorta.ifact1
|
||||
------------
|
||||
|
||||
1#`ld2*#`ld3*#`ld4*#`ld5*#`ld6*#`ld7*#`ld8*#`ld9*#`ld10*#`ld
|
||||
|
||||
This is a very straightforward factorial program: Take 1, print it,
|
||||
multiply by 2, print it, multiply by 3, print it, etc.
|
||||
|
||||
|
||||
sorta.ifact2
|
||||
------------
|
||||
|
||||
[1+D2s*#`ld1s]:f
|
||||
1 0
|
||||
1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f
|
||||
|
||||
ifact1 does a lot of repeated work. ifact2 takes advantage of this by
|
||||
keeping the current n! n on the stack. Each call to routine f (1=f)
|
||||
increments n by 1 and prints out the factorial.
|
||||
|
||||
|
||||
sorta.ifact3
|
||||
------------
|
||||
|
||||
[1+D2s*#`ld1s]:f [ given (n-1)! (n-1), print n!, put n! n ]
|
||||
[2s1=f2s1_+D0>=x]:x [ given n n! x, print (n+1)! through (n+x)! ]
|
||||
0 1 10 1=x
|
||||
|
||||
Finally, ifact3 removes all the redundancy from ifact2, and exhibits
|
||||
proper documentation of stack routines. You can replace the 10 by
|
||||
anything in this version.
|
||||
|
||||
|
||||
sorta.iio
|
||||
---------
|
||||
|
||||
[ a simple example of interpreting code on the fly ]ld
|
||||
|
||||
["] "2 2+":xT ["]T " produces "T 1=x#T " which should be 4."T`
|
||||
|
||||
Notice that "2 2+" is a literal string inside the program.
|
||||
|
||||
|
||||
sorta.irot13
|
||||
------------
|
||||
|
||||
"[] [.tr] "
|
||||
["]".[a-m][n-z][A-M][N-Z]"[" ]TTT ["]".[n-z][a-m][N-Z][A-M]"[" ]TTT
|
||||
"[tr] !q"T:xld
|
||||
["rot13: fatal: need exactly one argument"`q]:gld
|
||||
["rot13: fatal: cannot open "1ST`q]:hld
|
||||
a2_+=g
|
||||
1A 0 [ that 0 is for RDONLY ]ld
|
||||
0 'o D0 1s>=hld
|
||||
0Ou1=x [ in a more complex spawner, this would be done under a fork ]ld
|
||||
|
||||
Despite its name, irot13 is meant to show how to exec a program with
|
||||
redirection from within sorta. You run it as sorta blah < irot13; it
|
||||
opens blah and runs a (BSD-style) tr command to rotate all letters by 13
|
||||
spots. 1A 0 0 o opens argv[1]; the ' keeps the filename around for
|
||||
subroutine h to print a nice error message if necessary. 0Ou closes
|
||||
stdout and replaces it with the new descriptor. Finally, subroutine x
|
||||
executes the tr.
|
||||
|
||||
|
||||
sorta.isleep
|
||||
------------
|
||||
|
||||
["" "+sleep" "+5" "sleep" !q]:S [F0>1_+=S]:s
|
||||
"forking sleep 5..."`ld
|
||||
1=s
|
||||
"waiting for sleep to finish..."`ld
|
||||
w
|
||||
"done, sleep exit code " #T`
|
||||
|
||||
This script illustrates the classic fork-exec-wait.
|
||||
|
||||
|
||||
sorta.itailrec
|
||||
--------------
|
||||
|
||||
[3*#" "T$ldD=f]:f
|
||||
1=f
|
||||
|
||||
The sole purpose of this script is to prove that sorta can do infinite
|
||||
tail recursion (in this case, in program f). Do sorta < itailrec | more
|
||||
and watch the powers of 3 (mod your computer's word size) flow by.
|
||||
|
||||
|
||||
sorta.iwhosort
|
||||
--------------
|
||||
|
||||
[0Ou "" "+-u" "sort" !q]:S [F0>1_+=S]:s
|
||||
[1Ou "" "+-u" "who" !q]:W [F0>1_+=W]:w
|
||||
P1=wO1=sOww
|
||||
|
||||
This final example is a simple pipeline, who | sort.
|
||||
@@ -0,0 +1 @@
|
||||
2 2+#` [ about as basic as you can get ]ld
|
||||
@@ -0,0 +1 @@
|
||||
0A` [ take arg 0, print it ]
|
||||
@@ -0,0 +1,33 @@
|
||||
[D2sD3s]:Dld [ input m n, output m n m n ]ld
|
||||
|
||||
[2*1=d]:cld [ aux routine for :d recursion ]ld
|
||||
[1=D1s>1Ds_+=c]:dld [ input m n, as long as n <= m double it, output m n ]ld
|
||||
|
||||
[D2s1s_+1s]:-ld [ input m n, output m-n n ]ld
|
||||
[1=D1s>1Ds_+#T=-2/D=1]:1ld [ aux routine for :@ ]ld
|
||||
[1D=d2/1=1ddd1 ]:!ld
|
||||
["0"Td]:0ld
|
||||
[DD=!1_+=0]:@ld [ input m, m assumed nonnegative,
|
||||
append binary representation of m to top of s stack ]ld
|
||||
|
||||
["-"T_]:+ld
|
||||
[D0 1s>=+1=@]:2ld [ input m, append - to top of s stack if m is negative,
|
||||
then append binary representation of abs(m) to
|
||||
top of s stack ]ld
|
||||
|
||||
[d1A:A2=A]:A 27182 a1>=A
|
||||
[d2A:A1=A]:A 3145 a2>=A
|
||||
|
||||
D # " in binary is "T 1=2 `ld
|
||||
1=Dd # " in binary is "T 1=2 `ld
|
||||
|
||||
1=D 1s# " + "T 1s#T " is "T + #Td `ld
|
||||
1=D 1s# " - "T 1s#T " is "T _+ #Td `ld
|
||||
1=D 1s# " * "T 1s#T " is "T * #Td `ld
|
||||
1=D 1s# " / "T 1s#T " is "T / #Td `ld
|
||||
1=D 1s# " % "T 1s#T " is "T 1=D/*_+ #Td `ld
|
||||
|
||||
1=D d "~ " #T " is "T D& #T$ld " (" 1=2 ")"T `ld
|
||||
1=D 1s# " & "T 1s#T " is "T &D& #T$ld " (" 1=2 ")"T `ld
|
||||
1=D 1s# " | "T 1s#T " is "T D&1sD&& #T$ld " (" 1=2 ")"T `ld
|
||||
1=D 1s# " ^ "T 1s#T " is "T 1=D&2sD&1sD&&&D& #T$ld " (" 1=2 ")"T `ld
|
||||
@@ -0,0 +1,3 @@
|
||||
[ld#1_+1=y]:x
|
||||
[uD1+=x]:y
|
||||
0""1=y`
|
||||
@@ -0,0 +1,3 @@
|
||||
[" "$ld]:sld [ print a space ]ld
|
||||
[1s1+DA$ld1s1_+D=sD=x]:xld [ given n (argc-n), print args ]ld
|
||||
0a1_+D=x""` [ simulation of /bin/echo ]ld
|
||||
@@ -0,0 +1 @@
|
||||
1#`ld2*#`ld3*#`ld4*#`ld5*#`ld6*#`ld7*#`ld8*#`ld9*#`ld10*#`ld
|
||||
@@ -0,0 +1,3 @@
|
||||
[1+D2s*#`ld1s]:f
|
||||
1 0
|
||||
1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f 1=f
|
||||
@@ -0,0 +1,3 @@
|
||||
[1+D2s*#`ld1s]:f [ given (n-1)! (n-1), print n!, put n! n ]
|
||||
[2s1=f2s1_+D0>=x]:x [ given n n! x, print (n+1)! through (n+x)! ]
|
||||
0 1 10 1=x
|
||||
@@ -0,0 +1,3 @@
|
||||
[ a simple example of interpreting code on the fly ]ld
|
||||
|
||||
["] "2 2+":xT ["]T " produces "T 1=x#T " which should be 4."T`
|
||||
@@ -0,0 +1,9 @@
|
||||
"[] [.tr] "
|
||||
["]".[a-m][n-z][A-M][N-Z]"[" ]TTT ["]".[n-z][a-m][N-Z][A-M]"[" ]TTT
|
||||
"[tr] !q"T:xld
|
||||
["rot13: fatal: need exactly one argument"`q]:gld
|
||||
["rot13: fatal: cannot open "1ST`q]:hld
|
||||
a2_+=g
|
||||
1A 0 [ that 0 is for RDONLY ]ld
|
||||
0 'o D0 1s>=hld
|
||||
0Ou1=x [ in a more complex spawner, this would be done under a fork ]ld
|
||||
@@ -0,0 +1,6 @@
|
||||
["" "+sleep" "+5" "sleep" !q]:S [F0>1_+=S]:s
|
||||
"forking sleep 5..."`ld
|
||||
1=s
|
||||
"waiting for sleep to finish..."`ld
|
||||
w
|
||||
"done, sleep exit code " #T`
|
||||
@@ -0,0 +1,2 @@
|
||||
[3*#" "T$ldD=f]:f
|
||||
1=f
|
||||
@@ -0,0 +1,3 @@
|
||||
[0Ou "" "+-u" "sort" !q]:S [F0>1_+=S]:s
|
||||
[1Ou "" "+-u" "who" !q]:W [F0>1_+=W]:w
|
||||
P1=wO1=sOww
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# play tic-tac-toe
|
||||
|
||||
# parse args
|
||||
#
|
||||
if [ $# -gt 1 ]; then
|
||||
echo "usage: ttt [move_digit]" 1>&2
|
||||
echo " ttt quitgame" 1>&2
|
||||
echo " ttt clobber" 1>&2
|
||||
exit 1
|
||||
elif [ $# -eq 1 ]; then
|
||||
move="$1"
|
||||
else
|
||||
move=
|
||||
fi
|
||||
|
||||
# catch the clobber case
|
||||
#
|
||||
if [ clobber = "$move" ]; then
|
||||
echo "ttt: rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c" 1>&2
|
||||
rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c
|
||||
echo "ttt: rm -f merlyn.c merlyn.o merlyn" 1>&2
|
||||
rm -f merlyn.c merlyn.o merlyn
|
||||
echo "ttt: removed all but the original source" 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# catch the quitgame case
|
||||
#
|
||||
if [ quitgame = "$move" ]; then
|
||||
echo "ttt: rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c" 1>&2
|
||||
rm -f ttt_game ttt_game.o ttt_game.c ttt_old.c ttt_new.c
|
||||
echo "ttt: current game removed, perhaps you were going to lose? :-)" 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# watch for bad args
|
||||
#
|
||||
if [ $# -eq 1 ]; then
|
||||
case "$move" in
|
||||
1|2|3|4|5|6|7|8|9) ;;
|
||||
*) echo "ttt: bad argument" 1>&2
|
||||
echo "usage: ttt [move_digit]" 1>&2
|
||||
echo " ttt quitgame" 1>&2
|
||||
echo " ttt clobber" 1>&2
|
||||
exit 2 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# be sure that we have the merlyn.c source
|
||||
#
|
||||
if [ ! -f merlyn.c ]; then
|
||||
if [ -f westley.c ]; then
|
||||
echo "ttt: No merlyn.c around these parts, using a copy of westley.c" 1>&2
|
||||
cp westley.c merlyn.c
|
||||
chmod +w merlyn.c
|
||||
else
|
||||
echo "ttt: Ouch! merlyn.c and no westley.c are gone!" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
# check to see if the copy worked
|
||||
if [ ! -f merlyn.c ]; then
|
||||
echo "ttt: Darn, coundn't copy westley.c to merlyn.c" 1>&2
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
|
||||
# be sure we have the merlyn program
|
||||
#
|
||||
if [ ! -f merlyn ]; then
|
||||
echo "ttt: make merlyn" 1>&2
|
||||
make merlyn
|
||||
status=$?
|
||||
if [ "$status" -ne 0 ]; then
|
||||
echo "ttt: something is wrong, fix merlyn.c and build it yourself!" 1>&2
|
||||
echo " or maybe type: ttt clobber" 1>&2
|
||||
exit 5
|
||||
fi
|
||||
rm -f ttt_game.c
|
||||
fi
|
||||
|
||||
# If we don't have a ttt_game.c, or we cannot write it, make a new ttt_game.c
|
||||
#
|
||||
if [ ! -w ttt_game.c ]; then
|
||||
rm -f ttt_game.c
|
||||
if [ -z "$move" ]; then
|
||||
merlyn | tee ttt_game.c
|
||||
else
|
||||
merlyn "$move" | tee ttt_game.c
|
||||
fi
|
||||
chmod +w ttt_game.c
|
||||
|
||||
# If we have a ttt_game.c, then assume that we are in the process of playing
|
||||
#
|
||||
else
|
||||
rm -f ttt_game ttt_new.c
|
||||
echo "ttt: make ttt_game" 1>&2
|
||||
make ttt_game
|
||||
status=$?
|
||||
if [ "$status" -ne 0 ]; then
|
||||
echo "ttt: something is wrong, fix ttt_game.c and build it yourself!" 1>&2
|
||||
echo " or maybe type: ttt quitgame" 1>&2
|
||||
exit 6
|
||||
fi
|
||||
if [ -z "$move" ]; then
|
||||
ttt_game | tee ttt_new.c
|
||||
else
|
||||
ttt_game "$move" | tee ttt_new.c
|
||||
fi
|
||||
chmod +w ttt_new.c
|
||||
if [ -s ttt_new.c ]; then
|
||||
mv ttt_game.c ttt_old.c
|
||||
mv ttt_new.c ttt_game.c
|
||||
|
||||
# Check for win, lose, or draw
|
||||
# For a win or draw, copy merlyn.c to ttt_game.c
|
||||
# For a loss, copy ttt_game.c to merlyn.c, as it is now better
|
||||
# Also remove the executable for the file replaced
|
||||
# For anything else, game in progress, do not do anything
|
||||
|
||||
if [ -n "`grep ':-(' ttt_game.c`" ]; then
|
||||
echo
|
||||
echo "ttt: I lose...I won't make THAT mistake again!"
|
||||
chmod +w merlyn.c
|
||||
mv ttt_game.c merlyn.c
|
||||
rm -f merlyn ttt_game
|
||||
else
|
||||
if [ -n "`grep ':-)' ttt_game.c`" ]; then
|
||||
echo
|
||||
echo "ttt: I win!"
|
||||
cp merlyn.c ttt_game.c
|
||||
rm -f ttt_game
|
||||
else
|
||||
if [ -z "`grep 'X=-. ' ttt_game.c`" -a -z "`grep '^. ' ttt_game.c`" ]; then
|
||||
echo
|
||||
echo "ttt: It's a draw - play again?"
|
||||
cp merlyn.c ttt_game.c
|
||||
rm -f ttt_game
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
echo "ttt: something is wrong, maybe ttt_old.c will help" 1>&2
|
||||
echo " or maybe type: ttt quitgame" 1>&2
|
||||
echo " or maybe type: ttt clobber" 1>&2
|
||||
exit 7
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
a(X){/*/X=- a(X){/*/X=-
|
||||
-1;F;X=- -1;F;X=-
|
||||
-1;F;}/*/ -1;F;}/*/
|
||||
char*z[]={"char*z[]={","a(X){/*/X=-","-1;F;X=-","-1;F;}/*/","9999999999 :-| ",
|
||||
"int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*",
|
||||
"z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z",
|
||||
"[R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(",
|
||||
"9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&",
|
||||
"~Z));}R(){for(k=J[*J-48]-40;k;)e(w[k--],X|O);}main(u,v)char**v;{a(q=1);b(1);",
|
||||
"c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X",
|
||||
",O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N",
|
||||
";s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}",0};
|
||||
b(X){/*/X=- b(X){/*/X=-
|
||||
-1;F;X=- -1;F;X=-
|
||||
-1;F;}/*/ -1;F;}/*/
|
||||
int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*
|
||||
z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z
|
||||
[R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(
|
||||
9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&
|
||||
~Z));}R(){for(k=J[*J-48]-40;k;)e(w[k--],X|O);}main(u,v)char**v;{a(q=1);b(1);
|
||||
c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X
|
||||
,O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N
|
||||
;s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}
|
||||
c(X){/*/X=- c(X){/*/X=-
|
||||
-1;F;X=- -1;F;X=-
|
||||
-1;F;}/*/ -1;F;}/*/
|
||||
@@ -0,0 +1,180 @@
|
||||
Grand Prize:
|
||||
|
||||
Brian Westley (Merlyn LeRoy on usenet)
|
||||
DigiBoard, Inc.
|
||||
1026 Blair Ave.
|
||||
St. Paul, MN 55104 USA
|
||||
|
||||
|
||||
Judges' comments:
|
||||
|
||||
Make and run as follows:
|
||||
|
||||
make westley
|
||||
westley [move_location] | tee nextmove.c
|
||||
|
||||
where the 'move_location' is a digit from 1 to 9 that represents
|
||||
a move on a tic-tac-toe board:
|
||||
|
||||
1 2 3
|
||||
4 5 6
|
||||
7 8 9
|
||||
|
||||
If you omit 'move_location', then the computer moves first. For your
|
||||
next move, recompile nextmove.c and play it again:
|
||||
|
||||
make nextmove
|
||||
nextmove move_location | tee nextmove.c
|
||||
|
||||
We have provided the shell script, ttt, to make it easier to play the game:
|
||||
|
||||
make ttt
|
||||
ttt [first_move] <- omit first arg to have it move first
|
||||
ttt next_move
|
||||
|
||||
The shell script determines when the game is over, and automatically
|
||||
replaces merlyn.c with an improved version after a loss. The ttt script
|
||||
has two other modes:
|
||||
|
||||
ttt quitgame <- cancel any game in process, revert to merlyn.c
|
||||
ttt clobber <- remove all game files, revert to original source
|
||||
|
||||
Try not to cheat, the computer has not learned how to catch you doing it.
|
||||
|
||||
|
||||
Selected notes from the author:
|
||||
|
||||
A tic-tac-toe self-modifying program that "learns". This C program
|
||||
plays standard tic-tac-toe on itself. The code is written as a
|
||||
tic-tac-toe grid; moves are carried out within the code.
|
||||
|
||||
The human is X, the computer 0 [sic, "zero", not letter "O"].
|
||||
|
||||
The program, when run, reproduces itself with both the player's
|
||||
move and the computer's move added. Recompile THIS program (using
|
||||
the same compile line) and repeat until the game is finished.
|
||||
|
||||
If the computer wins, the "straight face" in the upper right-hand
|
||||
corner ":-|" will change into a happy face ":-)". If it is a draw,
|
||||
the face does not change. If the computer loses, the board is
|
||||
blanked and the face changes into a sad face ":-(". If this
|
||||
happens, the blank board should replace the original program; the
|
||||
computer changes its play and will continue to do so until it no
|
||||
longer loses games.
|
||||
|
||||
If you want a program that never loses, simply replace the string
|
||||
"9999999999 :-| " with "9883857753 :-| ".
|
||||
|
||||
How It Works (rot13 to read)
|
||||
----------------------------
|
||||
|
||||
Gur iregvpny "onef" bs gur tevq ner vqragvpny shapgvbaf, jvgu gur
|
||||
anzr bs gur shapgvba nf n(), o(), be p(). Nsgre rnpu shapgvba vf
|
||||
pnyyrq, gur tybony inevnoyrf K naq B pbagnva ovgznfxf bs jurer nyy
|
||||
gur Kf naq Bf ner cynprq. Gur fgngrzrag:
|
||||
|
||||
K=- <pune> -1;
|
||||
|
||||
rinyhngrf gb 1, -1, be -2 jura K vf 1 naq <pune> vf bar bs "K",
|
||||
"0", be " ". Gur shapgvba F(&K) frgf gur nccebcevngr ovgf va
|
||||
(tybony ine) K naq B naq erfrgf gur inyhr bs &K gb 1. Guvf vf ubj
|
||||
gur pheerag cbfvgvba vf pbzchgrq.
|
||||
|
||||
Gur cynlre'f zbir vf BE'q vagb gur K znfx, naq (vs vg vf gur
|
||||
bcravat zbir) gur fgengrtl fgevat'f svefg punenpgre vf frg gb gur
|
||||
cynlre'f svefg zbir (be "5" vs gur pbzchgre zbirf svefg).
|
||||
|
||||
Gur rinyhgvba shapgvba l(Z) purpxf vs gur znfx unf n jvaavat
|
||||
cnggrea (nal bs gur svefg rvtug ovgznfxf bs gur j[] neenl), naq
|
||||
frgf gur inevnoyr d gb 0 vs vg qbrf.
|
||||
|
||||
Gur cynlre'f zbir vf rinyhngrq gb frr vs gur uhzna unf jba. Gur
|
||||
fzvyrl vf frg gb :-) be :-( qrcraqvat ba guvf. Nyfb, vs gur uhzna
|
||||
unf jba, gur qvtvg va gur fgengrtl fgevat vf qrperzragrq gb punatr
|
||||
gur pbzchgre'f cynl sbe arkg tnzr.
|
||||
|
||||
Vs gur uhzna unf ABG jba, gur r(A,Z) shapgvba rinyhngrf vs NAL zbir
|
||||
abg va znfx A pna cebqhpr n jva va znfx Z. Gur svefg rinyhngvba
|
||||
r(K,B) purpxf vs B pna znxr n yrtny jvaavat zbir. Vs fb, gur
|
||||
pbzchgre unf n jvaavat zbir naq znxrf vg. Vs abg, gur fzvyrl vf
|
||||
frg gb :-|, naq n aba-jvaavat zbir vf trarengrq.
|
||||
|
||||
N aba-jvaavat zbir svefg purpxf vs K pna jva va bar zbir; vs fb,
|
||||
guvf zbir vf fryrpgrq, oybpxvat gur jva. Bgurejvfr, n zbir vf
|
||||
trarengrq ol ybbxvat qbja gur yvfg bs "zbir grzcyngrf". Gur svefg
|
||||
zbir grzcyngr gung trarengrf n zbir gung vf ABG nyernql bpphcvrq ol
|
||||
na K be B vf erghearq.
|
||||
|
||||
Gur "zbir grzcyngrf" ner fgngvp gvp-gnp-gbr cbfvgvbaf gung trarengr
|
||||
cbffvoyr zbirf ol znxvat gur r() shapgvba erghea "jvaavat" zbirf,
|
||||
r.t. gur grzcyngr:
|
||||
|
||||
. . .
|
||||
B , B (guvf vf gur inyhr 40; 2^3+2^5)
|
||||
. . . ("B"f ner 1 ovgf, "." naq "," ner 0 ovgf)
|
||||
|
||||
...jvyy znxr gur r() shapgvba erghea n pragre zbir, nf
|
||||
guvf vf gur bayl zbir gung cebqhprf guerr va n ebj. Abgvpr gung
|
||||
gur pbzchgre qbrf abg pbafvqre juvpu pryyf pbagnva Kf naq Bf jura
|
||||
znxvat n grzcyngr zbir, bayl juvpu pryyf ner rzcgl naq abg-rzcgl.
|
||||
Guvf znxrf sbe hahfhny cynl.
|
||||
|
||||
Gur grzcyngrf ner pnershyyl pubfra gb riraghnyyl oybpx nyy gencf
|
||||
gung K pna gel, ol whfg oyhaqrevat va gur jnl.
|
||||
|
||||
Nyfb abgr gung gur jvaavat & fgengrtl grzcyngrf ner cneg bs gur
|
||||
pbzcvyr yvar, znxvat vg cbffvoyr gb punatr gur ehyrf bs gur tnzr ol
|
||||
punatvat gur pbzcvyr yvar.
|
||||
|
||||
Gur grzcyngrf ner:
|
||||
|
||||
B , B
|
||||
, , ,
|
||||
B , B
|
||||
|
||||
, . .
|
||||
. B .
|
||||
. . B
|
||||
|
||||
. . .
|
||||
B , B
|
||||
. . .
|
||||
|
||||
. . .
|
||||
B B ,
|
||||
. . .
|
||||
|
||||
. . .
|
||||
B , B
|
||||
. . .
|
||||
|
||||
. , ,
|
||||
. B .
|
||||
B B ,
|
||||
|
||||
B , B
|
||||
, , .
|
||||
B . .
|
||||
|
||||
, . B
|
||||
B , B
|
||||
B . ,
|
||||
|
||||
B . ,
|
||||
B , B
|
||||
, . B
|
||||
|
||||
B , B
|
||||
, , ,
|
||||
B , B
|
||||
|
||||
N qvtvg bs "9" zrnaf fgneg jvgu gur svefg grzcyngr, "8" fgnegf ng
|
||||
gur frpbaq, rgp. Gur grzcyngrf ner fpnaarq hagvy n yrtny zbir vf
|
||||
sbhaq. N grzcyngr vf fpnaarq sebz obggbz gb gbc, evtug gb yrsg
|
||||
(v.r. zbir 9 vf grfgrq svefg, gura 8, qbja gb zbir 1).
|
||||
|
||||
Copyright (c) 1991, 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.
|
||||
Reference in new issue
Block a user