[net.lang.c] Winners of the 1986 International Obfuscated C Code Contest

chongo@nsc.UUCP (Landon Noll) (06/23/86)

          1986 International Obfuscated C Code Contest Winners


We recommend that you first try to understand the program from just reading
the source.  If you are still confused try sending the source through the C
Preprocessor (/lib/cpp).  If you are still confused, we suggest you read the
judges comments and run each program.  Last, if you are still confused then
you are not alone!


===============================================================================
Best layout:

	Eric Marshall
	System Development Corporation, a Burroughs Company
	P.O. Box 517
	Paoli, PA.
	19301

	sdcrdcf!burdvax!eric	{sjuvax,ihnp4,akgua,cadre}!psuvax1!burdvax!eric
-------------------------------------------------------------------------------
                                                   extern int
                                                       errno
                                                         ;char
                                                            grrr
                             ;main(                           r,
  argv, argc )            int    argc                           ,
   r        ;           char *argv[];{int                     P( );
#define x  int i,       j,cc[4];printf("      choo choo\n"     ) ;
x  ;if    (P(  !        i              )        |  cc[  !      j ]
&  P(j    )>2  ?        j              :        i  ){*  argv[i++ +!-i]
;              for    (i=              0;;    i++                   );
_exit(argv[argc- 2    / cc[1*argc]|-1<<4 ]    ) ;printf("%d",P(""));}}
  P  (    a  )   char a   ;  {    a  ;   while(    a  >      "  B   "
  /* -    by E            ricM    arsh             all-      */);    }
===============================================================================



===============================================================================
Worst abuse of the C preprocessor:

	Jim Hague
	University of Kent at Canterbury
	Canterbury, Kent
	UK

	..mcvax!ukc!jmh
-------------------------------------------------------------------------------
#define	DIT	(
#define	DAH	)
#define	__DAH	++
#define DITDAH	*
#define	DAHDIT	for
#define	DIT_DAH	malloc
#define DAH_DIT	gets
#define	_DAHDIT	char
_DAHDIT _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3d2f16g7c8a90l?e'b.s;i,d:"
;main			DIT			DAH{_DAHDIT
DITDAH			_DIT,DITDAH		DAH_,DITDAH DIT_,
DITDAH			_DIT_,DITDAH		DIT_DAH DIT
DAH,DITDAH		DAH_DIT DIT		DAH;DAHDIT
DIT _DIT=DIT_DAH	DIT 81			DAH,DIT_=_DIT
__DAH;_DIT==DAH_DIT	DIT _DIT		DAH;__DIT
DIT'\n'DAH DAH		DAHDIT DIT		DAH_=_DIT;DITDAH
DAH_;__DIT		DIT			DITDAH
_DIT_?_DAH DIT		DITDAH			DIT_ DAH:'?'DAH,__DIT
DIT' 'DAH,DAH_ __DAH	DAH DAHDIT		DIT
DITDAH			DIT_=2,_DIT_=_DAH_;	DITDAH _DIT_&&DIT
DITDAH _DIT_!=DIT	DITDAH DAH_>='a'?	DITDAH
DAH_&223:DITDAH		DAH_ DAH DAH;		DIT
DITDAH			DIT_ DAH __DAH,_DIT_	__DAH DAH
DITDAH DIT_+=		DIT DITDAH _DIT_>='a'?	DITDAH _DIT_-'a':0
DAH;}_DAH DIT DIT_	DAH{			__DIT DIT
DIT_>3?_DAH		DIT			 DIT_>>1 DAH:'\0'DAH;return
DIT_&1?'-':'.';}__DIT DIT			DIT_ DAH _DAHDIT
DIT_;{DIT void DAH write DIT			1,&DIT_,1 DAH;}
===============================================================================



===============================================================================
Best one liner:

	Jan Stein
	Chalmers Computer Society
	Gothenburg
	Sweden

	..!mcvax!enea!chalmers!gustaf!cd-jan

[The single line has been split to avoid any problems with E-mailers]
-------------------------------------------------------------------------------
typedef char*z;O;o;_=33303285;main(b,Z)z Z;{b=(b>=0||(main(b+1,Z+1),
*Z=O%(o=(_%25))+'0',O/=o,_/=25))&&(b<1||(O=time(&b)%0250600,
main(~5,*(z*)Z),write(1,*(z*)Z,9)));}
===============================================================================



===============================================================================
Most adaptable program:

	Jack Applin
	Hewlett-Packard
	Ft. Collins
	Colorado
	USA

	ihnp4!hplabs!hpfcdc!jack
-------------------------------------------------------------------------------
cat =13 /*/ >/dev/null 2>&1; echo "Hello, world!"; exit
*
*  This program works under cc, f77, and /bin/sh.
*
*/; main() {
      write(
cat-~-cat
     /*,'(
*/
     ,"Hello, world!"
     ,
cat); putchar(~-~-~-cat); } /*
     ,)')
      end
*/
===============================================================================



===============================================================================
Most useful obfuscation:

	Walter Bright
	<Email address not given>

	decwrl!sun!fluke!uw-beaver!entropy!dataio!bright
-------------------------------------------------------------------------------
#include <stdio.h>
#define O1O printf
#define OlO putchar
#define O10 exit
#define Ol0 strlen
#define QLQ fopen
#define OlQ fgetc
#define O1Q abs
#define QO0 for
typedef char lOL;

lOL*QI[] = {"Use:\012\011dump file\012","Unable to open file '\x25s'\012",
 "\012","   ",""};

main(I,Il)
lOL*Il[];
{	FILE *L;
	unsigned lO;
	int Q,OL[' '^'0'],llO = EOF,

	O=1,l=0,lll=O+O+O+l,OQ=056;
	lOL*llL="%2x ";
	(I != 1<<1&&(O1O(QI[0]),O10(1011-1010))),
	((L = QLQ(Il[O],"r"))==0&&(O1O(QI[O],Il[O]),O10(O)));
	lO = I-(O<<l<<O);
	while (L-l,1)
	{	QO0(Q = 0L;((Q &~(0x10-O))== l);
			OL[Q++] = OlQ(L));
		if (OL[0]==llO) break;
		O1O("\0454x: ",lO);
		if (I == (1<<1))
		{	QO0(Q=Ol0(QI[O<<O<<1]);Q<Ol0(QI[0]);
			Q++)O1O((OL[Q]!=llO)?llL:QI[lll],OL[Q]);/*"
			O10(QI[1O])*/
			O1O(QI[lll]);{}
		}
		QO0 (Q=0L;Q<1<<1<<1<<1<<1;Q+=Q<0100)
		{	(OL[Q]!=llO)? /* 0010 10lOQ 000LQL */
			((D(OL[Q])==0&&(*(OL+O1Q(Q-l))=OQ)),
			OlO(OL[Q])):
			OlO(1<<(1<<1<<1)<<1);
		}
		O1O(QI[01^10^9]);
		lO+=Q+0+l;}
	}
	D(l) { return l>=' '&&l<='\~';
}
===============================================================================



===============================================================================
Best simple task performed in a complex way:

	Bruce Holloway
	Digital Research, Inc.
	Monterey, CA
	USA

	(ucbvax!hplabs!amdahl!drivax!holloway)
-------------------------------------------------------------------------------
#include "stdio.h"
#define	e 3
#define	g (e/e)
#define	h ((g+e)/2)
#define	f (e-g-h)
#define	j (e*e-g)
#define k (j-h)
#define	l(x) tab2[x]/h
#define	m(n,a) ((n&(a))==(a))

long tab1[]={ 989L,5L,26L,0L,88319L,123L,0L,9367L };
int tab2[]={ 4,6,10,14,22,26,34,38,46,58,62,74,82,86 };

main(m1,s) char *s; {
    int a,b,c,d,o[k],n=(int)s;
    if(m1==1){ char b[2*j+f-g]; main(l(h+e)+h+e,b); printf(b); }
    else switch(m1-=h){
	case f:
	    a=(b=(c=(d=g)<<g)<<g)<<g;
	    return(m(n,a|c)|m(n,b)|m(n,a|d)|m(n,c|d));
	case h:
	    for(a=f;a<j;++a)if(tab1[a]&&!(tab1[a]%((long)l(n))))return(a);
	case g:
	    if(n<h)return(g);
	    if(n<j){n-=g;c='D';o[f]=h;o[g]=f;}
	    else{c='\r'-'\b';n-=j-g;o[f]=o[g]=g;}
	    if((b=n)>=e)for(b=g<<g;b<n;++b)o[b]=o[b-h]+o[b-g]+c;
	    return(o[b-g]%n+k-h);
	default:
	    if(m1-=e) main(m1-g+e+h,s+g); else *(s+g)=f;
	    for(*s=a=f;a<e;) *s=(*s<<e)|main(h+a++,(char *)m1);
	}
}
===============================================================================



===============================================================================
Best non-simple performed in a complex way:

	Lennart Augustsson
	Dept. of Comp. Sci.
	Chalmers University of Technology,
	412 96 Gothenburg
	Sweden

	augustss@chalmers.{uucp,csnet}
-------------------------------------------------------------------------------
typedef struct n{int a:3,
b:29;struct n*c;}t;t*
f();r(){}m(u)t*u;{t*w,*z;
z=u->c,q(z),u->b=z->b*10,
w=u->c=f(),w->a=1,w->c=z->
c;}t*k;g(u)t*u;{t*z,*v,*p,
*x;z=u->c,q(z),u->b=z->b,v
=z->c,z->a=2,x=z->c=f(),x
->a=3,x->b=2,p=x->c=f(),p
->c=f(),p->c->a=1,p->c->c=
v;}int i;h(u)t*u;{t*z,*v,*
w;int c,e;z=u->c,v=z->c,q(
v),c=u->b,e=v->b,u->b=z->b
,z->a=3,z->b=c+1,e+9>=c&&(
q(z),e=z->b,u->b+=e/c,w=f(
),w->b=e%c,w->c=z->c,u->c=
w);}int(*y[4])()={r,m,g,h};
char *sbrk();main(){t*e,*p,*o;
o=f(),o->c=o,o->b=1,e=f(),
e->a=2,p=e->c=f(),p->b=2,
p->c=o,q(e),e=e->c,(void)write
(1,"2.",2);for(;;e=e->c){q(e),
e->b=write(1,&e->b["0123456789"],
1);}}t*f(){return i||(i=1000,
k=(t*)sbrk(i*sizeof(t))),k+--i;
}q(p)t*p;{(*y[p->a])(p);}
===============================================================================



===============================================================================
Most illegible code:

 	Michael H. Pawka
	Naval Ocean Systems Center
	San Diego, Ca
	92152

	DDN - PAWKA@NOSC-TECR.ARPA
-------------------------------------------------------------------------------
#include "stdio.h"
#define xyxx char
#define xyyxx putchar
#define xyyyxx while
#define xxyyyx int
#define xxxyyx main
#define xyxyxy if
#define xyyxyy '\n'
xyxx *xyx [] = {
"]I^x[I]k\\I^o[IZ~\\IZ~[I^|[I^l[I^j[I^}[I^n[I]m\\I]h",
"]IZx\\IZx[IZk\\IZk[IZo_IZ~\\IZ~[IZ|_IZl_IZj\\IZj]IZ}]IZn_IZm\\IZm_IZh",
"]IZx\\IZx[I^k[I\\o]IZ~\\IZ~\\I]|[IZl_I^j]IZ}]I^n[IZm\\IZm_IZh",
"]IZx\\IZx[IZk\\IZk[IZo_IZ~\\IZ~_IZ|[IZl_IZj\\IZj]IZ}]IZn_IZm\\IZm]IZh",
"]I^x[I]k\\IZo_I^~[I^|[I^l[IZj\\IZj]IZ}]I^n[I]m^IZh",'\0'};/*xyyxyxyxxxyxxxyy*/
xyxx *xyyx; xxyyyx xyyyx,xyyyyx,xyyyyyx=0x59,xyyyyyyx=0x29,/*yxxyxyyyxxyyyxyy*/
xxyx=0x68;xxxyyx(){xyyyyx=0;xyyyxx(xyx[xyyyyx]){xyyx=xyx[xyyyyx++];/*xyyyxxyx*/
xyyyxx(*xyyx){xyyyx= *xyyx++-xyyyyyx;xyyyxx(xyyyx--)xyyxx(*xyyx-xyyyyyyx);/*x*/
xyxyxy(*xyyx==xxyx)xyyxx(xyyxyy);*xyyx++;}}}/*xyxyxyyyyxxyxxxyyyxyyyxyxxyyy*/
===============================================================================


===============================================================================
The grand prize (most well-rounded in confusion):

 	Larry Wall
	System Development Corporation
	Santa Monica
	California
	US of A

 	{allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
-------------------------------------------------------------------------------
#define _c(C)_ (C)&('|'+3):c_()(C)>>('\n'-3) __ /**/
#define C char*
#define keyboard ",,B3-u;.(&*5., /(b*(1\036!a%\031m,,,,,\r\n"
#define main(o,oo)oo(o){
#define _ ;case
C
#define c_(cc)c cc=
#define C_(sand)_O(sand)witch
o=keyboard;
#define __ ;break;
C
ccc(
cc)
C
cc;
{
C
cccc=
cc;int
#ifndef lint
#define keyboard "dijs QH.soav Vdtnsaoh DmfpaksoQz;kkt oa, -dijs"
#endif
c;
main(;c_(=(*cc);*cc++)c,for);
#define _O(s)s
main(0xb+(c>>5),C_(s))
_'\v'
:__ _'\f':
main(c,C_(s));
_c(8098)_c(6055)_c(14779)_c(10682)
#define O_(O)_O(O)stem(ccc(
_c(15276)_c(11196)_c(15150)
#define _C ;return
_c(11070)_c(15663)_c(11583)
}
__
default
:c_(+)o[c&__LINE__-007];
main(c_(-)'-'-1,C_(s))_
0214
:_
0216
:c_(+)025 _
0207
:c_(-)4 _
0233
:c_(+)' '-1;
}}c_(&)'z'+5;
}_C cccc;
}main(,cc)
C
#define O write(1,
c="O";
O_(sy) keyboard));
main(;;,for);
read(0,
c,1);*
c_(&)'~'+1
;O ccc(
c),
'\0');
main(*c,
C_(s));_
4
:O_(sy)";kkt -oa, dijszdijs QQ"))_C
_
13
:O o+' ',
3
)
#undef main
__ _ 127:O"\b \b",3)__
default
:O
c,1)
__}}}main(){
cc();
}
===============================================================================


===============================================================================
Judges comments:

    Best layout:	
	Compile and execute and post on your wall.

    Worst abuse of the C preprocessor:
	Compile and execute.  Feed it chars from standard input.
	Works with international standard rather than the US standard.
	Passes lint.

    Best one liner:
	Join the 3 lines into one line.  Compile and link to the
	filename 'a.out'.  Execute it the following 2 character
	argument: ^M^L (Return/Formfeed).  Passes lint.

    Most adaptable program:
	Compile and/or execute in several ways as documented.

    Most useful obfuscation:
	Compile and execute.  Give a filename as an argument.

    Best simple task performed in a complex way:
	Compile and execute and understand how it works!

    Best non-simple performed in a complex way:
	Compile and execute.  Works best with an infinite amount of
	stack space.  (otherwise a 'segmentation violation' eventually
	occurs)  Do an 'unlimit stacksize' command if your system
	allows it.  Passes lint.

    Most illegible code:
	Read, compile and execute.

    The grand prize (most well-rounded in confusion):
	Compile and execute.  Feed it chars from a standard input.
	The C compiler documents this program during compliation.
	Note the /lib/ccom message and compare it to what the program does!

===============================================================================

We received over twice the number of entries this year, than we did
last year.  Judging this year was made more difficult due to the number
of very good entries received.  We elected to break down several of the
contest categories rather than exclude some programs.

Thank you to all persons who entered the contest.  We hope you will try
again next year.

This years winning programs will be published in the Micro/Systems Journal,
issue date to be announced.  They may also wind up in at least one book,
datails to be announced in this newsgroup later.

===============================================================================

The 1987 contest:

Late 1986 entries or early 1987 entries will be entered into next year's
contest and will be subject to the 1987 rules (to be posted April 1987).

Lint passage will likely become more important in 1987.  Not as many
programs linted (or compiled) without flaws as in 1985/1984.  An award
solely for obfuscation via #defines ("worst abuse of the C pre-processor")
may not be awarded next year unless the program is of paticular merit.
This is intended to try and cut down on the number of programs in this
catagory.  To help the judges, we are considering a request that all
entries be sent in under shar format.  To help the readers, we will likely
post the 1987 winners under shar format with a makefile.  See the upcomming
1987 rules for details.

Send suggestions and/or comments about this contest to ...!decwrl!nsc!obfuscate.
Send comments about net.wobegon to ...!sun!chuq.  :-)

===============================================================================


chongo           <Landon Curt Noll - decwrl!nsc!chongo>      /\oo/\
Larry Bassel	 <decwrl!nsc!oblio!lab>

chongo@nsc.UUCP (Landon Noll) (06/25/86)

The following program:

>	The grand prize (most well-rounded in confusion):
> 
>  		Larry Wall
>		<lines deleted to save space>
> 
>  		{allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
>	-----------------------------------------------------------------------
>	#define _c(C)_ (C)&('|'+3):c_()(C)>>('\n'-3) __ /**/
>		<lines deleted to save space>

does not compile on most System V systems.  Several Sys V /lib/ccp's have
problems with the first define.  The following modification allows it
compile:

	1c1
	< #define _c(C)_ (C)&('|'+3):c_()(C)>>('\n'-3) __ /**/
	---
	> #define _c(C)_ (C)&('|'+3):c_()(C)>>('\n'-3) __; /**/

Our decisions are final.  But we can say:  "sorry about that folks!"

Next year, we would like to obtain help in running 'nominated' programs
in different machines.  We will solicit such help near the proper time.

chongo <oops, but we still think it is this year's best> /\__/\

chongo@nsc.UUCP (Landon Noll) (06/26/86)

In article <3661@nsc.UUCP> chongo@nsc.UUCP (Landon Noll) writes:
 >The following program:
 >
 >>	The grand prize (most well-rounded in confusion):
 >>		<lines deleted to save space>
 >
 >does not compile on most System V systems.  Several Sys V /lib/ccp's have
 >problems with the first define. 

I should have asked:  Is this a Sys V bug, or feature?

BTW: Some people have problems with the train program.  Our BSD snd Sys V.2
compilers give compiler warnings.  Your C compiler may flag it as fatal,
but it does execute and print a single message on our systems.


chongo <> /\oo/\

uddeborg@chalmers.UUCP (G|ran Uddeborg) (06/28/86)

In article <3656@nsc.UUCP> chongo@nsc.UUCP writes:
>Worst abuse of the C preprocessor:
>
>	Jim Hague
>	University of Kent at Canterbury
>	Canterbury, Kent
>	UK
>
>	..mcvax!ukc!jmh
>-------------------------------------------------------------------------------
>#define	DIT	(
>#define	DAH	)
>#define	__DAH	++
>#define DITDAH	*
>#define	DAHDIT	for
>#define	DIT_DAH	malloc
>#define DAH_DIT	gets
>#define	_DAHDIT	char
>_DAHDIT _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3d2f16g7c8a90l?e'b.s;i,d:"

There's a bug here.  _DAH_[] should be initiated to

_DAHDIT _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3c2g16g7c8a90l?e'b.s;i,d:"
						  ^ ^

Try input "2", and you'll see the bug.
-- 
"For me, UNIX is a (way of) being."

	G|ran Uddeborg
	UUCP:  {seismo,mcvax}!enea!chalmers!uddeborg
	CSnet: uddeborg@chalmers.csnet

jan@myab.UUCP (Jan Stein) (06/28/86)

In article <3656@nsc.UUCP> chongo@nsc.UUCP writes:
>    Best one liner:
>	Join the 3 lines into one line.  Compile and link to the
>	filename 'a.out'.  Execute it the following 2 character
>	argument: ^M^L (Return/Formfeed).  Passes lint.

You get a better result if you compile and link to the filename
'timeinGMT'. Then execute it with:

	timeinGMT ; echo ''

-=-
	Jan Stein
  {seismo,okstate,garfield,decvax,philabs}!mcvax!enea!chalmers!myab!jan