v15i108: International Obfuscated C Code Contest, Part04/07
Rich Salz
rsalz at bbn.com
Wed Aug 3 06:39:05 AEST 1988
Submitted-by: Landon Curt Noll <chongo at uts.amdahl.com>
Posting-number: Volume 15, Issue 108
Archive-name: ioccc/part04
# This is a shell archive. Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file". (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
#
# ./1985/Makefile ./1985/README ./1985/applin.c ./1985/applin.hint
# ./1985/august.c ./1985/august.hint ./1985/lycklama.c
# ./1985/lycklama.hint ./1985/rules ./1985/shapiro.c ./1985/shapiro.hint
# ./1985/sicherman.c ./1985/sicherman.hint
echo x - ./1985/Makefile
sed -e 's/^X//' > "./1985/Makefile" << '//E*O*F ./1985/Makefile//'
X# %W% %G% %U%
X#
X# 1985 makefile
X
XSHELL=/bin/sh
XWINNERS= applin august lycklama shapiro sicherman
X
Xall: ${WINNERS}
X
Xapplin: applin.c
X cc $? -o $@
Xaugust: august.c
X cc $? -o $@
Xlycklama: lycklama.c
X cc $? -o $@
Xshaprio: shaprio.c
X cc $? -o $@
Xscherman: sicherman.c
X cc $? -o $@
X
Xclean:
X rm -f core
Xclobber: clean
X rm -f ${WINNERS}
X
Xinstall: all
X @echo are you kidding'??'
//E*O*F ./1985/Makefile//
echo x - ./1985/README
sed -e 's/^X//' > "./1985/README" << '//E*O*F ./1985/README//'
XIn 1985, the second Obfuscated C Code Contest was held. Hints against
Xmachine dependent code were added to the rules to avoid another 1984
Xstyle winner. Rules and results were posted to net.lang.c and
Xnet.unix-wizards. Larry Bassel was invited to help in the judging.
XAwards were given to 5 classes of programs since we were unable to
Xselect only the best 4.
//E*O*F ./1985/README//
echo x - ./1985/applin.c
sed -e 's/^X//' > "./1985/applin.c" << '//E*O*F ./1985/applin.c//'
Xmain(v,c)char**c;{for(v[c++]="Hello, world!\n)";(!!c)[*c]&&(v--||--c&&execlp(*c,*c,c[!!c]+!!c,!c));**c=!c)write(!!*c,*c,!!**c);}
//E*O*F ./1985/applin.c//
echo x - ./1985/applin.hint
sed -e 's/^X//' > "./1985/applin.hint" << '//E*O*F ./1985/applin.hint//'
XBest one liner: <hp-dcd!jack> Jack Applin [with help from Robert Heckendorn]
X
XOne liner programs are short but twisted. This "Hello, World" version
Xcertainly takes its time saying hello.
//E*O*F ./1985/applin.hint//
echo x - ./1985/august.c
sed -e 's/^X//' > "./1985/august.c" << '//E*O*F ./1985/august.c//'
X#define p struct c
X#define q struct b
X#define h a->a
X#define i a->b
X#define e i->c
X#define o a=(*b->a)(b->b,b->c)
X#define s return a;}q*
X#define n (d,b)p*b;{q*a;p*c;
X#define z(t)(t*)malloc(sizeof(t))
Xq{int a;p{q*(*a)();int b;p*c;}*b;};q*u n a=z(q);h=d;i=z(p);i->a=u;i->b=d+1;s
Xv n c=b;do o,b=i;while(!(h%d));i=c;i->a=v;i->b=d;e=b;s
Xw n o;c=i;i=b;i->a=w;e=z(p);e->a=v;e->b=h;e->c=c;s
Xt n for(;;)o,main(-h),b=i;}main(b){p*a;if(b>0)a=z(p),h=w,a->c=z(p),a->c->a=u,
Xa->c->b=2,t(0,a);putchar(b?main(b/2),-b%2+'0':10);}
//E*O*F ./1985/august.c//
echo x - ./1985/august.hint
sed -e 's/^X//' > "./1985/august.hint" << '//E*O*F ./1985/august.hint//'
XThe most obscure program<chalmers!augustss>: Lennart Augustsson
X
XAn interesting use of a recursive call to main. Compile and execute
Xwithout args. What is the initial value of b, and does it alter the
Xaction of the program?
X
XIf you let it, the program will continue to print a numerical sequence
X(can you guess in what base it is printed?) until you run out of
Xmemory or until they sell your computer, which ever comes first.
//E*O*F ./1985/august.hint//
echo x - ./1985/lycklama.c
sed -e 's/^X//' > "./1985/lycklama.c" << '//E*O*F ./1985/lycklama.c//'
X#define o define
X#o ___o write
X#o ooo (unsigned)
X#o o_o_ 1
X#o _o_ char
X#o _oo goto
X#o _oo_ read
X#o o_o for
X#o o_ main
X#o o__ if
X#o oo_ 0
X#o _o(_,__,___)(void)___o(_,__,ooo(___))
X#o __o (o_o_<<((o_o_<<(o_o_<<o_o_))+(o_o_<<o_o_)))+(o_o_<<(o_o_<<(o_o_<<o_o_)))
Xo_(){_o_ _=oo_,__,___,____[__o];_oo ______;_____:___=__o-o_o_; _______:
X_o(o_o_,____,__=(_-o_o_<___?_-o_o_:___));o_o(;__;_o(o_o_,"\b",o_o_),__--);
X_o(o_o_," ",o_o_);o__(--___)_oo _______;_o(o_o_,"\n",o_o_);______:o__(_=_oo_(
Xoo_,____,__o))_oo _____;}
//E*O*F ./1985/lycklama.c//
echo x - ./1985/lycklama.hint
sed -e 's/^X//' > "./1985/lycklama.hint" << '//E*O*F ./1985/lycklama.hint//'
XThe strangest appearing program: <ism780!ed> Ed Lycklama
X
XRun the program without any arguments. Type in some very long lines
Xand notice how it redisplays it.
X
XThe program itself looks like tty noise. Notice that even `define' in
X#define can be defined.
//E*O*F ./1985/lycklama.hint//
echo x - ./1985/rules
sed -e 's/^X//' > "./1985/rules" << '//E*O*F ./1985/rules//'
XWARNING: The rules and mailing address for the contest change from year
X to year. Be sure that you consult the current set of rules
X before submitting entries.
X--------------------------------------------------------------------------------
X
XIt is time once again for the net wide Obfuscated C code contest!
X
XGOAL: To write the most Obscure working C program under the rules below:
X
XRULES: 1) The source must be 512 bytes or less.
X 2) Mail your entries to: ...!ihnp4!nsc!chongo
X Postings to the net will NOT be used!
X 3) Include at the top of the letter:
X a) Your name, and path from a major network node.
X If you want your entry to be anonymous, indicate this as well.
X b) A brief statement of what the program should do.
X c) The machine/opsys on which it runs.
X 4) Enclose your source between the following lines:
X---start of program---
X<place obfuscated source here>
X---end of program---
X 5) The C program must be written in common C.
X That is, K&R plus common extensions (say 4.2 or Sys V C)
X 6) The program must be of original work.
X 7) The program must be a complete program. (i.e., not just a fragment)
X 8) Entries must be received by me on or before June 8, 1985.
X
XPOINTS: Each entry will be judged for its non-clarity. I will attempt to
X run each of them on a Vax 780/4.2BSD system. Don't let the lack
X of such a system stop you! Try to avoid operating system/machine
X specific code if you do not have such a system. Extra points will
X be given for program that:
X
X a) Able to pass lint without complaint
X b) Actually does something interesting (not just exit)
X c) are portable (i.e., no special calls of local features)
X (long variable names will be allowed as needed)
X
XThe names of the winners will be posted to net.lang.c. The winning
Xsources will be posted to net.sources.
X
XIf you have any questions on the rules/points above, just ask via mail!
X
Xchongo <main(){int i;i+=i+++++i;exit(i);}> /\??/\
//E*O*F ./1985/rules//
echo x - ./1985/shapiro.c
sed -e 's/^X//' > "./1985/shapiro.c" << '//E*O*F ./1985/shapiro.c//'
X#define P(X)j=write(1,X,1)
X#define C 39
Xint M[5000]={2},*u=M,N[5000],R=22,a[4],l[]={0,-1,C-1,-1},m[]={1,-C,-1,C},*b=N,
X*d=N,c,e,f,g,i,j,k,s;main(){for(M[i=C*R-1]=24;f|d>=b;){c=M[g=i];i=e;for(s=f=0;
Xs<4;s++)if((k=m[s]+g)>=0&&k<C*R&&l[s]!=k%C&&(!M[k]||!j&&c>=16!=M[k]>=16))a[f++
X]=s;if(f){f=M[e=m[s=a[rand()/(1+2147483647/f)]]+g];j=j<f?f:j;f+=c&-16*!j;M[g]=
Xc|1<<s;M[*d++=e]=f|1<<(s+2)%4;}else e=d>b++?b[-1]:e;}P(" ");for(s=C;--s;P("_")
X)P(" ");for(;P("\n"),R--;P("|"))for(e=C;e--;P("_ "+(*u++/8)%2))P("| "+(*u/4)%2
X);}
//E*O*F ./1985/shapiro.c//
echo x - ./1985/shapiro.hint
sed -e 's/^X//' > "./1985/shapiro.hint" << '//E*O*F ./1985/shapiro.hint//'
XGrand prize for most well-rounded in confusion: <otto!carl> Carl Shapiro
X
XAs submitted, this program was 3 lines (2 of defines and 1 of code).
XTo make news & mail happy we split the last line into 7. Join them
Xback without the newlines to get the original version.
X
XThis program was selected for the 1987 t-shirt collection.
X
XWe found this program is be simply aMAZEing! Run this program without
Xarguments and notice the output.
//E*O*F ./1985/shapiro.hint//
echo x - ./1985/sicherman.c
sed -e 's/^X//' > "./1985/sicherman.c" << '//E*O*F ./1985/sicherman.c//'
X#define C_C_(_)~' '&_
X#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n')
X#define C_C _|_
X#define b *
X#define C /b/
X#define V _C_C(
Xmain(C,V)
Xchar **V;
X/* C program. (If you don't
X * understand it look it
X */ up.) (In the C Manual)
X{
X char _,__;
X while (read(0,&__,1) & write((_=(_=C_C_(__),C)),
X _C_,1)) _=C-V+subr(&V);
X}
Xsubr(C)
Xchar *C;
X{
X C="Lint says "argument Manual isn't used." What's that
X mean?"; while (write((read(C_C('"'-'/*"'/*"*/))?__:__-_+
X '\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
X}
//E*O*F ./1985/sicherman.c//
echo x - ./1985/sicherman.hint
sed -e 's/^X//' > "./1985/sicherman.hint" << '//E*O*F ./1985/sicherman.hint//'
XThe worst abuse of the C preprocessor: <sunybcs!colonel> Col. G. L. Sicherman
X
XThis program abuses the C preprocessor so much that some /lib/cpp's fail to
Xstrip out all of the comments on the first pass! If you were able to
Xunderstand Decot's entry in 1984, you will have a head start on this
Xone.
X
XBe sure to run this program through lint! If your lint works
Xcorrectly, it should warn you that the argument `Manual' isn't used.
XLike the program says, what's that mean?
X
XRun the program without arguments and enter the letters 'a' thru 'm'
Xon a line. Now enter the letters 'n' thru 'z'. But to borrow a quote
Xfrom Richard Stallman: If you think you understand what this code
Xdoes, then you don't, so read it again! Explain why:
X
X sicherman < sicherman.c | sicherman | diff - sicherman.c
X
Xresults in diff reporting a difference on some machines.
//E*O*F ./1985/sicherman.hint//
echo Possible errors detected by \'wc\' [hopefully none]:
temp=/tmp/shar$$
trap "rm -f $temp; exit" 0 1 2 3 15
cat > $temp <<\!!!
27 62 370 Makefile
6 62 362 README
1 2 129 applin.c
4 28 188 applin.hint
14 45 513 august.c
9 74 428 august.hint
17 48 509 lycklama.c
7 41 256 lycklama.hint
44 322 1958 rules
9 18 518 shapiro.c
10 74 430 shapiro.hint
23 64 511 sicherman.c
19 150 850 sicherman.hint
190 990 7022 total
!!!
wc ./1985/Makefile ./1985/README ./1985/applin.c ./1985/applin.hint ./1985/august.c ./1985/august.hint ./1985/lycklama.c ./1985/lycklama.hint ./1985/rules ./1985/shapiro.c ./1985/shapiro.hint ./1985/sicherman.c ./1985/sicherman.hint | sed 's=[^ ]*/==' | diff -b $temp -
exit 0
--
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.
More information about the Comp.lang.c
mailing list