Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming IT Technology

IOCCC Accepting New, 'Improved' Entries 144

Rudolf writes: "The 16th International Obfuscated C Code Contest is open from now until 01 Dec 2001 23:59:59 UTC. Details are at the IOCCC web site. From the front page, the contest goals are: -- To write the most Obscure/Obfuscated C program (within contest rules -- To show the importance of programming style, in an ironic way. -- To stress C compilers with unusual code. -- To illustrate some of the subtleties of the C language. -- To provide a safe forum for poor C code. :-)"
This discussion has been archived. No new comments can be posted.

IOCCC Accepting New, 'Improved' Entries

Comments Filter:
  • To stress C compilers with unusual code

    Some compilers become stressed easier than others.
    • Typically each year we find that at least 1 entry that will cause someone's C compiler to dump core or go haywire.

      Over the years, gcc has survived the best. It has chucked core cookies on a few entries, but not nearly as often as some of the commercial C compilers.

      If a winning entry does cause problems for somebody's C compiler, we usually file a bug report. They may not be pleased with the code sample, but that is the break;'s. :-)

      p.s. The entry that broke causde the most problems on the most platforms was the 1988 Best of show [ioccc.org]. Not only did it crash a few C pre-processors, it cause one system to turn casters-up when it ran out of swap space!

  • Cute site (Score:2, Funny)

    by Matey-O ( 518004 )
    Anybody notice the 'A is for ASCII, B is for Byte' stuff on the winners index?

    link [ioccc.org]
  • russians will win? (Score:2, Interesting)

    by weinford ( 97037 )
    I once heard, it may be a rumour, but at least it's a nice story, that (once upon a time) russian coders liked to write code with obfuscation built in. They were so scared to loose their jobs that they wrote code only themselves could understand, using strange/misleading variable names, senseless loops or whatever. Can anyone confirm this? I think it's a nice technique ;-) Maybe the compiled code is even easier to understand...
    • by Anonymous Coward
      It would not be the first time I read the assembly generated by the compiler to understand what the damned C code meant.


      There are cases, often with complex logical expression with deeply nested parenthese, && and ||, where the assembly is easier to read than
      the so called "high level" source code.
      (Well, C is not high-level in any case)

    • by Anonymous Coward
      I once heard, it may be a rumour, but at least it's a nice story, that (once upon a time) russian coders liked to write code with obfuscation built in. They were so scared to loose their jobs that they wrote code only themselves could understand, using strange/misleading variable names, senseless loops or whatever. Can anyone confirm this?

      It's a well documented phenomena [tuxedo.org].
      • Not in my short experience. The Russians i work or worked with have high standards for readability. Sometimes weak knowledge of english causes misunderstandings.

        Once upon a time and once upon an office?
        It must have been tried somewhere, maybe in Russia. And then they start sweating to get the bugs out.

        The best way to make the code hard to decipher is to put a bad programmer on it. Although, in lisp...

    • Russian Coders? How about U.S. gorvernment coders?
    • Russians? Americans used to do the same thing. Maybe not with the misleading variable names, but obfuscation was part of the game. It wasn't until the 80s that people started shifting focus towards software development toward a more professional focus. During the 60s mostly (and into the 70s) you had the core-wars hacker types discovering what was possible and trying to push the envelope.

    • by Anonymous Coward
      In the early days of programming this was almost standard practice, EVERYWHERE!

      In the early days, IBM used to have "aptitude tests" that asked candidates whether they liked the "puzzles", e. g., in the newspapers and gave tests to evaluate this kind of "skill".

      It took only a short step for programmers to realize that all programs could be written as "puzzles". If weak management accepted this, then you have Microsoft!

      Now you know why all those old, old programs look the way they do!
    • by Anonymous Coward
      > it's a nice story, that (once upon a time) russian coders liked to write code with obfuscation built in.
      > Can anyone confirm this?

      I have one story that is true.

      When I worked on image recognition software (1999), the boss decided that we needed a new recognition engine. So he paid for some source code written by a Russian (the guy didn't speak English, with almost no net acess, and limited access to a phone.)

      It was the worst piece of inefficient spagitti (crap) code I have ever seen. Variables names like j1, j2, j3, j4, j20, j22, and hardcoded array access like x[4] = , x[50] =, x[52] =. It took me a few months of reverse engineering and cleaning it up. I ended up just chucking it away, and starting from scratch, which was a valuable lesson for me -- If you're spending most of your time refactoring existing code, it's better to just chuck it away and start fresh with a clean design.

      > Maybe the compiled code is even easier to understand...

      It was! I also found it usefull to treat each function as a black box, and figure out
      a) input (& are they const)
      b) outputs (& are they const)
      c) intermediate values

      Ironically we had a co-worker Russion coder that was half decent. A little inexperienced on good coding practises, but a hard worker, and I could depend on him to get tasks done.

      Obviously 2 people isn't a large statistical enough sample to draw any conclusions from.
    • At a previous employer, we had a home-grown database system (written in IBM mainframe assembler). We were a non-profit company, and perhaps because some of the development was paid for by the government, there was some stipulation that the source code back then had be made available to qualified parties.

      Worried that we would lose our intellectual property, the company hired a consultant to determine the best way to obfuscate the code before sharing it. After looking over the code, the consultant noted that we didn't need to do a thing to it to prevent others from understanding it!

      Ken (a 1997 winner of the IOCCC)

    • Heck, that's not unique to Russians. It's alive and well in the West, that's fer damnsure.

      Go to the Jargon File (www.jargon.org), and look up "job security".

  • by forgoil ( 104808 ) on Tuesday October 02, 2001 @07:31AM (#2377751) Homepage
    Or would that be too easy?;)
  • my fovorite (Score:4, Funny)

    by snatchitup ( 466222 ) on Tuesday October 02, 2001 @07:34AM (#2377758) Homepage Journal
    My favorite isn't so much obfuscated code, but hair-brained.. I've actually seen this by paid contract programmers......

    String getLetter( int index ){
    String [] x = { "A", "B", "C", "D" };
    for ( int i = 0; i < 4; i++ ){
    if ( i == 0 && index ==0 )
    return "A";
    else if ( i == 1 && index == 1 )
    return "B";
    else if ( i == 2 && index == 2 )
    return "C";
    else if ( i ==3 && index == 3 )
    return "D";

    if ( i >= 4 )
    break;
    }
    return null;
    }

    Are they getting paid by the line?
    • that's not even C... very nice
      • Well if you want to get really picky.

        int x[100];

        for(int iApple = 0; iApple < 100; ++iApple){
        iApple[x] = iApple;
        }

        for(int iGrape = 99; iGrape >= 0; --iGrape){
        printf("%d\n", (int)(99 - iGrape[x]));
        }
    • Re:my fovorite (Score:1, Flamebait)

      by n3m6 ( 101260 )
      there is no String s .. you half brained C++ trolls..
    • That's nothing... I once saw the following kn actual production code:


      /* look for the first non-blank */
      char *p;
      p = some_string;
      while (strncmp(p," ",1) == 0)
      p++;

    • (boolean expression) ? TRUE : FALSE;
      • Today I found this snippet of code:
        bool func()
        {
        if (true)
        return true;
        else
        return false;
        }
        (Well, the function once was useful and instead of completely erasing it, it was changed to this)

      • Actually that code does serve a purpose when programming on Windows/MFC/C++ systems. In MFC, TRUE is defined as the integer constant '1' and FALSE is defined as the integer constant '0'. Whereas the return from the boolean expression will either be the C++ boolean value 'true' or the C++ boolean value 'false'. And depending on the warning level of the compiler, it will complain/mention that you're converting a boolean to an integer, so adding the ? TRUE : FALSE will eliminate the warning.
        • So I guess it's not really a "C compiler, is it?
        • so adding the ? TRUE : FALSE will eliminate the warning.

          If you're using COM interfaces it gets worse than that. The VARIANT_BOOL data type is defined as a 16-bit word taking the values False (0) and True (-1). As long as you test these against false there's not usually a problem, but if you test equal to true rather than is true, or if you negate the variable then weird things can happen. VB's Not operator blindly does a bitwise rather than logical negation even on Booleans, so if you take a Boolean variable (badly) returned from a COM object written in C++ it's entirely possible for both the following statements to get executed:

          If var Then DoThis
          If Not var Then DoThat

          Solution: always return COM booleans from C++ using the idiom (var ? VARIANT_TRUE : VARIANT_FALSE)

    • When I was programming for large corporations as an independent contractor I would sometimes write code inefficiently like the example listed above.

      Why? Because many of the in-house 'programmers' weren't actually programmers; they were power users of particular apps programmed by others and critical to the operation of the company. No one else in the company was qualified to make the distinction, or technical enough to see that all the 'code' these guys wrote they downloaded from the internet and tweaked for their company's specs, while removing all copyright information.

      In other words, they didn't understand anything but the most basic of programming elements.

      When I was hired by these corporations I was usually handed off to the IS department and they would tell me what they'd want. I'd write a nice, elegant piece of code, turn it in, and they'd tell me to rewrite it because it was 'unnecessarily complicated'. Translation: they couldn't read it because they weren't capable of doing any real programming themselves. So I would often end up 'dumbing it down' until the IS people could follow along as I explained (in copious documentation) how everything worked.

      Sometimes it was incredibly embarrassing and I'd throw away the code rather than add it to my portfolio. The worst such moment came when I wrote a Perl app for one of North America's largest timber companies (which shall remain nameless) that I had to revise FIVE TIMES. The last iteration had no subroutines or function calls because *nobody in the IS department understood what a function or subroutine was*. So for the app I did everything with GOTO statements - because they understood GOTO.

      Yep. GOTO. Each and every jump in the code. GOTO. Quite challenging, actually, not being able to use subroutines or function calls. But it was so ugly, so heinous, and so...juvenile...I never told anyone about that job. I didn't want anyone to know that I'd written that incredible dog.

      Sometimes bad code is written by bad programmers. Sometimes bad code is written *for* bad programmers.

      Max
  • It's probably necessary to limit the contest to a specific language, but it would be cool to see a competition with other languages as well. Perhaps a limited set of "reasonable" languages (or everything will be written in esoteric (weird) languages (did anyone say Malbolge?).
    I'd really like to see obfuscated/weird code in a language less "obfuscatable" than C (maybe Java or somethingorother?).
    In that way, "obfuscation" can be more a matter of weird program flow and such, instead of confusing (but not very "interesting") a?b:c-statements (whatever they're called, I've forgotten it) and other C specialties.
    Obfuscation is more of a challenge if you don't have as many weird operators and such do go with, and you have to fool people some other way.
    Perhaps an Obfuscated Pseudo Code Contest?
    • If you think the IOCCC is mostly about ?:, then I don't think you've looked at enough entries! There is some truly twisted code in there, exploring every syntactic and semantic corner of the language.

      I doubt that other languages offer the same possibilities for befuddlement as C, but there's only one way to find out...

    • I'd really like to see obfuscated/weird code in a language less "obfuscatable" than C (maybe Java or somethingorother?).

      Just throwing obfuscated code constructs at the program isn't enough to win these days. (I know, I've tried.) To have a realistic chance of winning, your code has to excel in several ares of obfuscation (style, algorithm, abuse of the rules) and show economy and elegance and do something non-trivial.

      Check out the winner last year that fit an entire X-Windows flight simulator into 1.5K of C code... can't link to it right now, but it's called "banks.c".

      I'm going to enter again this year. I've got a program that I've progressively improved over several iterations. I just thought of a few ways to shave some bytes here and there; maybe I'll have enough room to squeeze in a graphical output routine...

    • Actually, the trinary operator is extremely useful and can clean up code if used right. Also, it exists in Java.


    • I humbly cast my vote on APL [izap.com]... It is a symbolic, naturally cryptic [chilton.com] ( warning: big gif of the non-ASCII charset ) language, delightful to use ( once you really grokked it ) just because of the amazing power of its one-liners [cloud9.net]...:-)
  • Anecdote (Score:5, Funny)

    by mirko ( 198274 ) on Tuesday October 02, 2001 @07:42AM (#2377776) Journal
    The following event was related by ace@tidbits.com (Adam C. Engst).

    The highlight of the annual Computer Bowl occurred when
    Bill Gates [ucr.edu],
    who was a judge, posed the following
    question [slashdot.org]
    to the contestants:


    "What contest, held via Usenet, is dedicated to examples of weird, obscure, bizarre, and really bad programming?"


    After a moment of silence, Jean-Louis Gassee (ex-honcho at Apple) hit his buzzer and answered:


    "Windows."


    Mr. Bill's expression was, in the words of one who was there, "classic."

    • This Computer Bowl story is true, BTW. I saw it on TV shortly after it happened. I marked out.
    • I was in the audience at that time. Note that most of the audience walked in were actually Mac developers. It was held in the same week, and across the street from, the World Wide Developer Conference held by Apple in San Jose.
  • Either the IOCCC has already been slashdotted or the obfuscated source of Apache is in recompilation.
  • void main(){
    printf("hello world!");
    }
    If that's not obscure, what is?
  • My favourite obfuscation is this pi-program [rutgers.edu].

    The only thing in main() is large drawing of a filled circle. And then it says

    "If you want better accuracy, make a bigger drawing"!
  • check out this [latech.edu]

    and look under the C link.
  • 1990 winner (Score:5, Interesting)

    by Lussarn ( 105276 ) on Tuesday October 02, 2001 @08:55AM (#2377943)
    This is the 1990 winner. A complete basic interpreter. For fun I unobfuscated this code (Took a couple of hours). it's really a piece of art. several commands. Variables. Parentesis and operator precedence. Cool Stuff.


    #define O(b,f,u,s,c,a)b(){int o=f();switch(*p++){X u:_ o s b();X c:_ o a b();default:p--;_ o;}}
    #define t(e,d,_,C)X e:f=fopen(B+d,_);C;fclose(f)
    #define U(y,z)while(p=Q(s,y))*p++=z,*p=' '
    #define N for(i=0;io&&!*z)_ x;}_ 0;}main(){m[11*R]="E";while(puts("Ok"),gets(B)
    )switch(*B){X'R':C=E;l=1;for(i=0;i",'#');U("=",' !' );}d=B;while(*F=*s){*s=='"'&&j
    ++;if(j&1||!Q(" \t",F))*d++=*s;s++;}*d--=j=0;if(B[1]!='=')switch(* B){X'E':l=-1
    X'R':B[2]!='M'&&(l=*--C)X'I':B[1]=='N'?gets(p=B) ,P [*d]=S():(*(q=Q(B,"TH"))=0,p
    =B+2,S()&&(p=q+4,l=S()-1))X'P':B[5]=='"'?*d=0,pu ts (B+6):(p=B+5,printf("%d\n",S
    ()))X'G':p=B+4,B[2]=='S'&&(*C++=l,p++),l=S()-1 X'F':*(q=Q(B,"TO"))=0;p=B+5;P[i
    =B[3]]=S();p=q+2;M[i]=S();L[i]=l X'N':++P[*d]',>)O(K,V,'$',=)
    O(V,W,'+',+,'-',-)O(W,Y,'*',*,'/',/)Y(){int o;_*p=='-'?p++,-Y():*p>='0'&&*p
    • Re:1990 winner (Score:2, Informative)

      by Lussarn ( 105276 )
      Grab it here instead [acc.umu.se]. The source where cut in the post.
    • Re:1990 winner (Score:2, Insightful)

      by Anonymous Coward
      I've always wished that they'd post an analysis of the various techniques used in each program. Sometimes the authors will explain some of the tricks they used, but it seems that most submitter's attitude is figure it out yourself.
    • Yes, your 1990 Best Language Tool [ioccc.org] was an outstanding entry. It was one of several of outstanding wins [ioccc.org] that I have had the pleasure of judging over the years.

      However, the greatest and longest laugh at a IOCCC BOF occurred when I presented your 1998 Best abuse of the rules [ioccc.org]. For those you were not there, his entry consisted of a single, simple Un*x portable line of code:

      #include "/dev/tty"
      That Truely twisted entry is listed in my top 10 all time best IOCCC progs.
  • a couple of my favs (Score:3, Interesting)

    by gosand ( 234100 ) on Tuesday October 02, 2001 @09:00AM (#2377965)
    I have had these for a while now, not sure where I got them. I tried to post the source, but it wouldn't let me. Check them out.

    When compiled and run, it prints out the 12 days of Christmas.

    12days.c [enteract.com]

    And this one is has very interesting source, I think it calculates pi.

    pi.c [enteract.com]

    • This one is funny: http://www.ioccc.org/1990/westley.c [ioccc.org]
      No clue what it does, but it's arranged as a series of letters.

      And you've gotta read the hint file [ioccc.org] for http://www.ioccc.org/1995/heathbar.c [ioccc.org].

      I can't find the one I wanted to link to... It was a program to print a maze, in the shape of a maze, that spelled the word "MAZE". Quite beautiful.
    • pi.c is one of those classics that's just to beautiful to describe. It's actually one of the easier winners to figure out (so I guess it's not *too* obfuscated), but it's so wonderful you can't help but to adore it. Can you figure out how it works? Here's a hint: carefully increase the size of the circle. You'll get a more accurate approximation of pi. Incredible.
  • You should take a look at the Shakespeare Programming Language [sourceforge.net], or SPL for short. It combines the best features of BASIC, assembly language, and Hamlet. In SPL, every program is a play, and the plot closely follows the program execution. You can program SPL for a living during the day, then come home and read the source code as a good-night story.

    How's that for obfuscation?
  • The best ones have always been those that abuse the rules, the compiler, or both.

    A few years back somebody submitted the definitive self-replicating (i.e. prints its own source code) program. It consisted of a 0-byte C file. The author pointed out that even though it's not technically a legal C program, most C compilers (including the one the IOCCC uses) will in fact accept it and proceed to spit out a binary that does nothing.

    The most evil entry though has to be the Spinellis entry from 1988, which consists of the line #include "/dev/tty". This actually caused a change in the rules so that programs can't require user intervention to compile anymore, short of running make.

    • by Anonymous Coward
      The author pointed out that even though it's not technically a legal C program, most C
      compilers (including the one the IOCCC uses) will in fact accept it and proceed to spit out a binary that does
      nothing.


      Let's see:

      # touch test.c
      # gcc test.c
      /usr/lib/crt1.o: In function `_start':
      /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
      collect2: ld returned 1 exit status

      Doesn't work anymore.
      • Sure it does. You forgot the -c switch.

        $ touch test.c
        $ gcc -c test.c
        $ ls -l test.?
        -rw-r--r-- 1 .. 0 Oct 2 16:09 test.c
        -rw-r--r-- 1 ... 488 Oct 2 16:09 test.o

        Null code will compile.. it just won't link on its own.
    • There are some good examples of quines (self-replicating programs) at http://www.nyx.net/~gthompso/quine.htm [nyx.net]

      Also, I like Esoteric Topics in Computer Programming [catseye.mb.ca]

  • Anyone got a mirror site/link?

    Brian
    --
    100% Linux Based Web Hosting [assortedinternet.com]

  • new to this contest (Score:5, Informative)

    by chongo ( 113839 ) on Tuesday October 02, 2001 @10:58AM (#2378466) Homepage Journal
    As part of the IOCCC tradition, we always tweak/adjust the rules [ioccc.org] and guidelines [ioccc.org] each year. Noteworthy changes for the 16th contest include:
    • New max size limits: 4096 (was 3217)
      (We gotta keep up with the code bloat like everyone else :-) :-()
    • New max size for non-whitespace / non {:} chars: 2048 (was 1536)
    • New max compile/build line: 521 (was 255)
      (why 521? Well 521 is prime and 2^521-1 is a Mersenne prime and I like primes ... :-))
    • We now allow people to use OpenMotif
    • MS gets two pot shots directed at it in this contest (yet another tradition)
  • I could really use an unobfuscater to translate all the code I write at 3:00am while on a Jolt/Vivarin high.

    It would also come in handy when I have to look at the code the interns wrote.

You are in a maze of little twisting passages, all different.

Working...