home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 181_01 / cforum.1_4 < prev    next >
Text File  |  1986-01-09  |  6KB  |  133 lines

  1. Reprinted from: Micro/Systems Journal, Volume 1. No. 4. Sep/Oct 1985     
  2. -----------------------------------------------------------------
  3. Copy of back issue may be obtained for $4.50 (foreign $6) from:
  4. Subscriptions are $20/yr, $35/2yrs domestic (published bimonthly)
  5. Micro/Systems Journal
  6. Box 1192
  7. Mountainside NJ 07092
  8. -----------------------------------------------------------------
  9. Copyright 1986
  10. Micro/Systems Journal, Box 1192, Mountainside NJ 07092
  11. This software is released into the public domain for
  12.  non-commercial use only.
  13. -----------------------------------------------------------------
  14.  
  15. The C Forum
  16.  
  17. by Don Libes
  18.  
  19. The 1985 Obfuscated C Code Contest
  20.  
  21.      In previous columns I discussed C programming techniques by 
  22. providing examples that are educational.  By that I mean that the 
  23. code is readable, easily-modifiable, portable, modular, well-
  24. commented, structured, etc.  I like to think of such well-written 
  25. code as "elegant".  Such programs should be a pleasure to read.  
  26. However, not everyone writes "beautiful" code, and I would be 
  27. amiss in my duties as an educator to ignore that fact.
  28.      Normally we don't consider it worthwhile to publish "ugly" 
  29. or unreadable code, but there are some examples that one can 
  30. actually learn by (much as I learned that a red flame was hot 
  31. when I stuck my hand in it).
  32.      Thus, it is with much pleasure (and a big grin - see picture 
  33. above) that I announce the 1985 Obfuscated C Code Contest.  This 
  34. contest is run by Landon Noll who collects the entries and then 
  35. wonders about how much thought the author must have put into 
  36. destroying an otherwise good piece of code.  Landon says,
  37.  
  38.      The contest was motivated by reading some Unix source code      
  39. (it was /etc/config from 4.2BSD).  I was shocked at how much 
  40. simple algorithms could be made cryptic, and therefore useless, 
  41. by a poor choice of code style.  "Could someone be proud of this 
  42. code?"
  43.  
  44. ENTERING THE CONTEST
  45.      The 1985 contest is now open.  The goal is to write the most 
  46. obscure C program within the rules below:
  47.  
  48. 1) The source must be 512 bytes or less.
  49. 2) Mail your entries to:
  50.      Landon Noll
  51.      3770 Flora Vista Ave. #705
  52.      Santa Clara CA 95051
  53.      or, via Usenet:   ...!ihnp4!nsc!chongo
  54.      or, mail them to Micro/Systems Journal and we will forward 
  55.         them to Landon.
  56. 3) Include at the top of the letter:
  57.      a) Your name and address.  If you want your entry to be 
  58.           anonymous, indicate this.
  59.      b) A brief statement of what the program should do.
  60.      c) The machine, OS and C compiler on which it runs.
  61. 4) Enclose your source between the following lines:
  62.      ---start of program---
  63.      <place obfuscated source here>
  64.      ---end of program---
  65. 5) The C program must be written in common C.  That is, K&R      
  66.      plus common extensions.
  67. 6) The program must be of original work.
  68. 7) The program must be a complete program. (i.e., not just a 
  69.           fragment)
  70. 8) Entries must be received on or before September 31, 1985.
  71.  
  72. GUIDELINES
  73.      Each entry will be judged for its non-clarity.  I will 
  74. attempt to run each of them on a Vax 780/4.2BSD system.   Don't 
  75. let the lack of such a system stop you!  Try to avoid operating 
  76. system/machine specific code if you do not have such a system.
  77.     Extra points will be given to programs that:
  78. a) pass lint without complaint.
  79. b) actually do something interesting  (not just exit).
  80. c) are portable (i.e., no special calls of local features).  Long 
  81.      variable names will be allowed as needed.
  82.  
  83.      Let me point out that the guidelines for this year give more 
  84. credit to lint/machine independent solutions.  Thus the winner 
  85. for 1984 would not be rated as high under this year's rules.
  86.      Good luck!
  87.  
  88. 1984 OBFUSCATED C CODE CONTEST WINNERS
  89.      The following are the top four entries from last year's 
  90. contest.  Please read them carefully.  If you think you 
  91. understand one, you've probably glanced at it too quickly.  These 
  92. programs are the most bizarre examples of C code that I've ever 
  93. seen.  (Yes, they're much worse than the UNIX sources.)  
  94. Amazingly, they all work.
  95.      They're not just good for a laugh.  Each one is good for 
  96. hours of study.  Not only do they show you what NOT to do, but 
  97. they teach you how to deal with very strange code.  Lastly, you 
  98. can actually learn some of the finer points of C by studying 
  99. these very unusual programs.
  100.  
  101. <DIS>HONORABLE MENTION FOR 1984:
  102. ------------------------------------------------------------
  103.  
  104. ------------------------------------------------------------
  105. AUTHOR: anonymous
  106. COMMENT: Too embarrassed that s/he could write such trash, I guess.
  107.  
  108. THIRD PLACE FOR 1984:
  109. ------------------------------------------------------------
  110.  
  111. ------------------------------------------------------------
  112. AUTHOR: Mike Laman
  113. UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman
  114. COMMENT: Accepts one positive argument.  Try something like "cmd 
  115.      37".
  116.  
  117. SECOND PLACE AWARD FOR 1984:
  118. ------------------------------------------------------------
  119.  
  120. ------------------------------------------------------------
  121. AUTHOR: Dave Decot
  122. UUCP: hplabs!hpda!hpdsd!decot
  123.  
  124.  
  125. FIRST PLACE AWARD FOR 1984:
  126. ------------------------------------------------------------
  127.  
  128. ------------------------------------------------------------
  129. AUTHORS: Sjoerd Mullender, Robbert van Renesse
  130. ADDRESS: Vrije Universiteit, Amsterdam, the Netherlands.
  131. UUCP: decvax!mcvax!vu44!{sjoerd,cogito}
  132. COMMENT: Try this on your local VAX or pdp-11.
  133.