home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume14 / ioccc / part03 < prev    next >
Encoding:
Internet Message Format  |  1988-03-14  |  10.2 KB

  1. Subject:  v14i003:  International Obfuscated C Code Contest, Part03/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Landon Curt Noll <chongo@uts.amdahl.com>
  7. Posting-number: Volume 14, Issue 3
  8. Archive-name: ioccc/part03
  9.  
  10. # This is a shell archive.  Remove anything before this line, then
  11. # unpack it by saving it in a file and typing "sh file".  (Files
  12. # unpacked will be owned by you and have default permissions.)
  13. #
  14. # This archive contains:
  15. # ./1985/Makefile ./1985/README ./1985/applin.c ./1985/applin.hint 
  16. # ./1985/august.c ./1985/august.hint ./1985/lycklama.c ./1985/lycklama.hint 
  17. # ./1985/rules ./1985/shapiro.c ./1985/shapiro.hint ./1985/sicherman.c 
  18. # ./1985/sicherman.hint
  19.  
  20. echo mkdir ./1985
  21. mkdir ./1985
  22. echo x - ./1985/Makefile
  23. sed -e 's/^X//' > "./1985/Makefile" << '//E*O*F ./1985/Makefile//'
  24. X# %W% %G% %U%
  25. X#
  26. X# 1985 makefile
  27. X
  28. XSHELL=/bin/sh
  29. XWINNERS= applin august lycklama shapiro sicherman
  30. X
  31. Xall: ${WINNERS}
  32. X
  33. Xapplin: applin.c
  34. X    cc $? -o $@
  35. Xaugust: august.c
  36. X    cc $? -o $@
  37. Xlycklama: lycklama.c
  38. X    cc $? -o $@
  39. Xshaprio: shaprio.c
  40. X    cc $? -o $@
  41. Xscherman: sicherman.c
  42. X    cc $? -o $@
  43. X
  44. Xclean:
  45. X    rm -f core
  46. Xclobber: clean
  47. X    rm -f ${WINNERS}
  48. X
  49. Xinstall: all
  50. X    @echo are you kidding'??'
  51. //E*O*F ./1985/Makefile//
  52.  
  53. echo x - ./1985/README
  54. sed -e 's/^X//' > "./1985/README" << '//E*O*F ./1985/README//'
  55. XIn 1985, the second Obfused C Code Contest was held.  Hints against
  56. Xmachine dependent code were added to the rules to avoid another 1984
  57. Xstyle winner.  Rules and results were posted to net.lang.c and
  58. Xnet.unix-wizards.  Larry Bassel was invited to help in the judging.
  59. XAwards were given to 5 classes of programs since we were unable to
  60. Xselect only the best 4.
  61. //E*O*F ./1985/README//
  62.  
  63. echo x - ./1985/applin.c
  64. sed -e 's/^X//' > "./1985/applin.c" << '//E*O*F ./1985/applin.c//'
  65. 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);}
  66. //E*O*F ./1985/applin.c//
  67.  
  68. echo x - ./1985/applin.hint
  69. sed -e 's/^X//' > "./1985/applin.hint" << '//E*O*F ./1985/applin.hint//'
  70. XBest one liner: <hp-dcd!jack> Jack Applin [with help from Robert Heckendorn]
  71. X
  72. XOne liner programs are short but twisted.  This "Hello, World" version
  73. Xcertainly takes its time saying hello.
  74. //E*O*F ./1985/applin.hint//
  75.  
  76. echo x - ./1985/august.c
  77. sed -e 's/^X//' > "./1985/august.c" << '//E*O*F ./1985/august.c//'
  78. X#define p struct c
  79. X#define q struct b
  80. X#define h a->a
  81. X#define i a->b
  82. X#define e i->c
  83. X#define o a=(*b->a)(b->b,b->c)
  84. X#define s return a;}q*
  85. X#define n (d,b)p*b;{q*a;p*c;
  86. X#define z(t)(t*)malloc(sizeof(t))
  87. 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
  88. Xv n c=b;do o,b=i;while(!(h%d));i=c;i->a=v;i->b=d;e=b;s
  89. Xw n o;c=i;i=b;i->a=w;e=z(p);e->a=v;e->b=h;e->c=c;s
  90. 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,
  91. Xa->c->b=2,t(0,a);putchar(b?main(b/2),-b%2+'0':10);}
  92. //E*O*F ./1985/august.c//
  93.  
  94. echo x - ./1985/august.hint
  95. sed -e 's/^X//' > "./1985/august.hint" << '//E*O*F ./1985/august.hint//'
  96. XThe most obscure program<chalmers!augustss>: Lennart Augustsson
  97. X
  98. XAn interesting use of a recursive call to main.  Compile and execute
  99. Xwithout args.  What is the initial value of b, and does it alter the
  100. Xaction of the program?
  101. X
  102. XIf you let it, the program will continue to print a numerical sequence
  103. X(can you guess in what base it is printed?) until you run out of
  104. Xmemory or until they sell your computer, which ever comes first.
  105. //E*O*F ./1985/august.hint//
  106.  
  107. echo x - ./1985/lycklama.c
  108. sed -e 's/^X//' > "./1985/lycklama.c" << '//E*O*F ./1985/lycklama.c//'
  109. X#define o define
  110. X#o ___o write
  111. X#o ooo (unsigned)
  112. X#o o_o_ 1
  113. X#o _o_ char
  114. X#o _oo goto
  115. X#o _oo_ read
  116. X#o o_o for
  117. X#o o_ main
  118. X#o o__ if
  119. X#o oo_ 0
  120. X#o _o(_,__,___)(void)___o(_,__,ooo(___))
  121. X#o __o (o_o_<<((o_o_<<(o_o_<<o_o_))+(o_o_<<o_o_)))+(o_o_<<(o_o_<<(o_o_<<o_o_)))
  122. Xo_(){_o_ _=oo_,__,___,____[__o];_oo ______;_____:___=__o-o_o_; _______:
  123. X_o(o_o_,____,__=(_-o_o_<___?_-o_o_:___));o_o(;__;_o(o_o_,"\b",o_o_),__--);
  124. X_o(o_o_," ",o_o_);o__(--___)_oo _______;_o(o_o_,"\n",o_o_);______:o__(_=_oo_(
  125. Xoo_,____,__o))_oo _____;}
  126. //E*O*F ./1985/lycklama.c//
  127.  
  128. echo x - ./1985/lycklama.hint
  129. sed -e 's/^X//' > "./1985/lycklama.hint" << '//E*O*F ./1985/lycklama.hint//'
  130. XThe strangest appearing program: <ism780!ed> Ed Lycklama
  131. X
  132. XRun the program without any arguments.  Type in some very long lines
  133. Xand notice how it redisplays it.
  134. X
  135. XThe program itself looks like tty noise.  Notice that even `define' in
  136. X#define can be defined.
  137. //E*O*F ./1985/lycklama.hint//
  138.  
  139. echo x - ./1985/rules
  140. sed -e 's/^X//' > "./1985/rules" << '//E*O*F ./1985/rules//'
  141. XWARNING: The rules and mailing address for the contest change from year
  142. X         to year.  Be sure that you consult the current set of rules
  143. X     before submitting entries.
  144. X--------------------------------------------------------------------------------
  145. X
  146. XIt is time once again for the net wide Obfuscated C code contest!
  147. X
  148. XGOAL:  To write the most Obscure working C program under the rules below:
  149. X
  150. XRULES:    1) The source must be 512 bytes or less.
  151. X    2) Mail your entries to:      ...!ihnp4!nsc!chongo
  152. X       Postings to the net will NOT be used!
  153. X    3) Include at the top of the letter:
  154. X        a) Your name, and path from a major network node.
  155. X           If you want your entry to be anonymous, indicate this as well.
  156. X        b) A brief statement of what the program should do.
  157. X        c) The machine/opsys on which it runs.
  158. X    4) Enclose your source between the following lines:
  159. X---start of program---
  160. X<place obfuscated source here>
  161. X---end of program---
  162. X    5) The C program must be written in common C. 
  163. X       That is, K&R plus common extensions (say 4.2 or Sys V C)
  164. X    6) The program must be of original work.
  165. X    7) The program must be a complete program. (i.e., not just a fragment)
  166. X    8) Entries must be received by me on or before June 8, 1985.
  167. X
  168. XPOINTS:    Each entry will be judged for its non-clarity.  I will attempt to
  169. X    run each of them on a Vax 780/4.2BSD system.   Don't let the lack
  170. X    of such a system stop you!  Try to avoid operating system/machine
  171. X    specific code if you do not have such a system.  Extra points will
  172. X    be given for program that:
  173. X
  174. X    a) Able to pass lint without complaint
  175. X    b) Actually does something interesting  (not just exit)
  176. X    c) are portable (i.e., no special calls of local features)
  177. X       (long variable names will be allowed as needed)
  178. X
  179. XThe names of the winners will be posted to net.lang.c.  The winning
  180. Xsources will be posted to net.sources.
  181. X
  182. XIf you have any questions on the rules/points above, just ask via mail!
  183. X
  184. Xchongo <main(){int i;i+=i+++++i;exit(i);}> /\??/\
  185. //E*O*F ./1985/rules//
  186.  
  187. echo x - ./1985/shapiro.c
  188. sed -e 's/^X//' > "./1985/shapiro.c" << '//E*O*F ./1985/shapiro.c//'
  189. X#define P(X)j=write(1,X,1)
  190. X#define C 39
  191. 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,
  192. 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;
  193. 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++
  194. 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]=
  195. Xc|1<<s;M[*d++=e]=f|1<<(s+2)%4;}else e=d>b++?b[-1]:e;}P(" ");for(s=C;--s;P("_")
  196. X)P(" ");for(;P("\n"),R--;P("|"))for(e=C;e--;P("_ "+(*u++/8)%2))P("| "+(*u/4)%2
  197. X);}
  198. //E*O*F ./1985/shapiro.c//
  199.  
  200. echo x - ./1985/shapiro.hint
  201. sed -e 's/^X//' > "./1985/shapiro.hint" << '//E*O*F ./1985/shapiro.hint//'
  202. XGrand prize for most well-rounded in confusion: <otto!carl> Carl Shapiro
  203. X
  204. XAs submitted, this program was 3 lines (2 of defines and 1 of code).
  205. XTo make news & mail happy we split the last line into 7. Join them
  206. Xback without the newlines to get the original version.
  207. X
  208. XThis program was selected for the 1987 t-shirt collection.
  209. X
  210. XWe found this program is be simply aMAZEing!  Run this program without
  211. Xarguments and notice the output.
  212. //E*O*F ./1985/shapiro.hint//
  213.  
  214. echo x - ./1985/sicherman.c
  215. sed -e 's/^X//' > "./1985/sicherman.c" << '//E*O*F ./1985/sicherman.c//'
  216. X#define C_C_(_)~' '&_
  217. X#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n')
  218. X#define C_C _|_
  219. X#define b *
  220. X#define C /b/
  221. X#define V _C_C(
  222. Xmain(C,V)
  223. Xchar **V;
  224. X/*    C program. (If you don't
  225. X *    understand it look it
  226. X */    up.) (In the C Manual)
  227. X{
  228. X    char _,__; 
  229. X    while (read(0,&__,1) & write((_=(_=C_C_(__),C)),
  230. X    _C_,1)) _=C-V+subr(&V);
  231. X}
  232. Xsubr(C)
  233. Xchar *C;
  234. X{
  235. X    C="Lint says "argument Manual isn't used."  What's that
  236. X    mean?"; while (write((read(C_C('"'-'/*"'/*"*/))?__:__-_+
  237. X    '\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
  238. X}
  239. //E*O*F ./1985/sicherman.c//
  240.  
  241. echo x - ./1985/sicherman.hint
  242. sed -e 's/^X//' > "./1985/sicherman.hint" << '//E*O*F ./1985/sicherman.hint//'
  243. XThe worst abuse of the C preprocessor: <sunybcs!colonel> Col. G. L. Sicherman
  244. X
  245. XThis program abuses the C preprocessor so much that some /lib/cpp's fail to
  246. Xstrip out all of the comments on the first pass!  If you were able to
  247. Xunderstand Decot's entry in 1984, you will have a head start on this
  248. Xone.
  249. X
  250. XBe sure to run this program through lint!  If your lint works
  251. Xcorrectly, it should warn you that the argument `Manual' isn't used.
  252. XLike the program says, what's that mean?
  253. X
  254. XRun the program without arguments and enter the letters 'a' thru 'm'
  255. Xon a line.  Now enter the letters 'n' thru 'z'.  But to borrow a quote
  256. Xfrom Richard Stallman: If you think you understand what this code
  257. Xdoes, then you don't, so read it again!  Explain why:
  258. X
  259. X    sicherman < sicherman.c | sicherman | diff - sicherman.c
  260. X
  261. Xresults in diff reporting a difference on some machines.
  262. //E*O*F ./1985/sicherman.hint//
  263.  
  264. echo Possible errors detected by \'wc\' [hopefully none]:
  265. temp=/tmp/shar$$
  266. trap "rm -f $temp; exit" 0 1 2 3 15
  267. cat > $temp <<\!!!
  268.      27     62    370 Makefile
  269.       6     62    359 README
  270.       1      2    129 applin.c
  271.       4     28    188 applin.hint
  272.      14     45    513 august.c
  273.       9     74    428 august.hint
  274.      17     48    509 lycklama.c
  275.       7     41    256 lycklama.hint
  276.      44    322   1958 rules
  277.       9     18    518 shapiro.c
  278.      10     74    430 shapiro.hint
  279.      23     64    511 sicherman.c
  280.      19    150    850 sicherman.hint
  281.     190    990   7019 total
  282. !!!
  283. 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=[^ ]*/==' | 
  284.  
  285. diff -b $temp -
  286. exit 0
  287.  
  288.