Slashdot Mirror


Obfuscated C Code Contest Begins

slashdot-me writes "The International Obfuscated C Code Contest (IOCCC) has begun. See the rules at the IOCCC homepage. The contest runs from Feb. 1 to March 31. " As always, the results will be only readable by Martians.

227 comments

  1. "#define @ ;" is not allowed ! :( by Anonymous Coward · · Score: 0

    Must be alphanumeric or underline.

  2. Re:Shortest Self Duplicating C program by Anonymous Coward · · Score: 0

    Indeed that was a submission to the ioccc a few years back.

    The grounds for accepting it were that, technically speaking, it is not an invalid program either (after all, is it a program?) and that some compilers took empty code and produced a program that does nothing. The makefile they included made sure it built correctly.

    (I'm teaching a intro programming class and just looked at the site monday, for horror stories for my class. Good I got there before it got slashdotted)

  3. Hrm... by Anonymous Coward · · Score: 0

    Wow... Petrified. You even *sound* like one of the Natalie Portman trolls.

    BTW: Have you ever thought about what language your Java and Scheme compilers are written in?

  4. Re:first by Anonymous Coward · · Score: 0
    lets make everybody happy, since it doesn't compile under C or C++ without adding things anyway, we can do the following:


    /* the dirty trick
    if (post.first()) { printf "FIRST POST!" }
    */
    /* now lets make C & C++ meet */
    #ifdef __cplusplus
    #include
    #define writeln(a) cout#else
    #include
    #define writeln(a) printf(a)
    #endif
    #define Begin int main() {
    #define End return 0;}

    Begin
    writeln("Reply to FIRST POST!");
    End

  5. Re:first by Anonymous Coward · · Score: 0
    Why do you say that's C++? Because of the "post.first()"? That's perfectly legal in C, assuming "post" is a structure that contains an element named "first" which is a function pointer.

    One of the great lies of the 20th century was that C doesn't support polymorphism. Absolutely untrue.

    C doesn't support polymorphism. What you are talking about is encapsulation.

    if you could do this:
    int foo(int c, char * w);
    int foo(int c, int w);

    then c would support polymorphism (but, as we know, you'd get an error about conflicting prototypes).

    Can you achieve the same effect in c? sure:
    int foo(void * c, void *w);

    then inside foo check to see what you really want to do. But, in the strictest sense, this isn't polymorphism, just a hackish way to emulate it.

  6. Bah! Even ordinary Perl code puts IOCCC to shame! by Anonymous Coward · · Score: 0

    C had obfuscation potential. Con/destructors/inheritance helped C++ do better, but for pure obfuscation, nothing beath Perl. Now, bad Perl... I'd rather not think about that. Even INTERCAL is more grokable.

  7. Obfuscated Code Contests by Anonymous Coward · · Score: 0
    Is there an obfuscated Perl contest?

    Some regular expressions are a work of art.

  8. Re:pascal rocks! by Anonymous Coward · · Score: 0

    And Delphi... when are we going to get a nice delphi port for linux?

  9. Re:www.ioccc.org by Anonymous Coward · · Score: 0

    Yes. And the most time-critical parts are still assembly. The kernel hackers do optimize the number of clock cycles spent in critical pieces of assembly code.

  10. Re:WHO CARES WHAT LINUX WAS WRITTEN IN!! by Anonymous Coward · · Score: 0

    Scheme? Are you nuts?!? This language, based on LISP, is so FUBAR with parentheses and lambda() cruft that Mandarin Chinese is easier to read! I was in a beginning programming class about 6 years ago where we used Scheme to learn OOP and structured programming. I had already had a semester of C++ before that, and had written in BASIC for years before on Atari 800(XL) systems. Our last project of the course was to right a program that would do something regarding a deck of cards; it's been so long I don't even remember what. I don't think anyone in the whole class of 40 people even finished the thing, and we had at least a month to do it! I don't even think the professor figured it out, and he'd been programming (or teaching it) for years himself. I won't touch Scheme again, even if I were paid to. C++ is the way to go, and none of this Win32 or MFC crap either.All my C++ experience has been with SGI IRIX. Unfortunately, it's all been small console apps so far, but if I had the time, I'd try to work up an X app or two under Linux. Scheme? Gimme a break!

  11. Or just submit any C++ program of your choice by Anonymous Coward · · Score: 0
    After all C++ is simply obfucscated C at the end of the day.

    dmg

  12. Re:Au Contraire! by Anonymous Coward · · Score: 0
    You should check into past entries in the IOCCC :)

    Seriously, there is no standard method for OO programming in C, so anything you do will be hard for others to understand, and if it's hard for others to understand, it'll be hard for you to understand too a few months after you write it.

  13. Re:Au Contraire! by Anonymous Coward · · Score: 0

    You can do multiple inheritance in C too, but you shouldn't just like you shouldn't do OO programming in C. (Hint: Use a language with predefined conventions for OO programming)

  14. Re:first by Anonymous Coward · · Score: 0

    I'll never win the contest with that...

  15. Re:Fixes by Anonymous Coward · · Score: 0

    Hey Woah!

    Took me a while to figure out that it's not pascal but c! Babe!

  16. Re:first by Anonymous Coward · · Score: 0

    Hehe - a double first.

    First post and funny too!

  17. No. That's called overloading. by Anonymous Coward · · Score: 0

    if you could do this:
    int foo(int c, char * w);
    int foo(int c, int w);

    then c would support polymorphism (but, as we know, you'd get an error about conflicting prototypes).


    No. That's called overloading.

    1. Re:No. That's called overloading. by Anonymous Coward · · Score: 0

      which is also known as polymorphism.

    2. Re:No. That's called overloading. by Anonymous Coward · · Score: 0

      Polymorphism is the ability of objects to inherit from parents but make modifications. Overloading is specifically to do with functions, where as polymorphism is used with objects. Lots of none oo languages can handle overloading, but polymorphism requires inheritance. E.G. You have a class called ANIMAL. It has a function WALK(). DOG and HUMAN both inherit from ANIMAL, they are special cases of ANIMAL and provide their own versions of WALK but keep many of the same properties. That's polymorphism. Overloading - 5 + 6 = 11 "foo " + "bar" = "foo bar" Overloading is general and works only on functions on operators (in Ada 95 you can overload basic operators like + in the same way you do on any other function to cope with ADTs). I could have written that more formally and acurately but I can't be bothered.

    3. Re:No. That's called overloading. by Anonymous Coward · · Score: 0

      polymorphism can be applied to objects (via inheritance) or to functions (via overloading). Just because the popular OO language of the week this week uses incorrect definitions doesn't change it.

      "in Ada 95 you can overload basic operators like +..." duh. same with C++. That too is a form of function polymorphism.

      And polymorphism can be done in C, via inheritance. Look at GTK's object system. The trick is to put the superclass's structure as the first element of the subclass's structure. That and some neat macro tricks will yeild you an OO language.

      This kind of thing is why I shudder when intro OO classes are taught in C++. A much better approach would be to start with Smalltalk, and move into C++ later. This "trade school" approach of only teaching the language that students will "need" in the real-world does them a disservice.

      And any school doesn't doesn't offer classes in LISP or something similar also gets the "trade school" stamp.

    4. Re:No. That's called overloading. by enterfornone · · Score: 1

      I think OO classes could be taught in C++, however most "trade schools" teach C then C++ - encouraging you to to a lot of non-OO things...

      --

      --
      enterfornone - logging in for a change
    5. Re:No. That's called overloading. by Old+Wolf · · Score: 1

      LOL @ LAMERS

      Polymorphism involves run-time decision of which function to call. No such thing can possibly happen with function (ie. function or operator) overloading.

  18. Re:Obfuscated PERL contest? by Anonymous Coward · · Score: 0

    Uh, isn't the meaning of a contest that someone should be able to win it?

    ;-)

  19. Re:LISP is readable? by Anonymous Coward · · Score: 0

    Anyone that complains of the number of parentheses in LISP or Scheme has not actually looked into it.

    printf ("Hello World\n");
    (display "Hello World\n");

    both have to parens, in fact all C function calls require parens except bastardisations like return #

    how about this:
    if (x) { printf("A\n"); } else { printf("B\n"); }
    vs.
    (if x (display "A\n") (display "B\n"))

    I dont know who is posting here, but it seems most of you have no experience with computer programming.
    -Adam Scislowicz (core@triton.net)

  20. Re:first language... by Anonymous Coward · · Score: 0

    Or an upgrade:

    getkey.com: 32 E4 CD 16 B4 4C CD 21

    sad, i have even MORe free time :)

  21. Re:first by Anonymous Coward · · Score: 0

    char far STRG_PRINT = {0x46, 0x69, 0x72, 0x73, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x00}; while( (unsigned char far*)(&STRG_PRINT++)!=NULL) outputbuf->Stringdump((unsigned char far *)(&STRG_PRINT++));

  22. Re:first by Anonymous Coward · · Score: 0

    char far STRG_PRINT = {0x46, 0x69, 0x72, 0x73, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x00};


    while( (unsigned char far*)(&STRG_PRINT++)!=NULL)
    outputbuf->Stringdump((unsigned char far *)/(&STRG_PRINT++));

    // time to whip out my good ol' Borland Turbo...


  23. Re:Hey! by Anonymous Coward · · Score: 0

    Get a job...
    Take this crap somewhere else..

  24. Re:first by Anonymous Coward · · Score: 0

    Won't work

    #define

    where identifier is a started with an alphabetic character (or underscore) followed by any letter, number, or underscore.

  25. Microsoft has it in the bag by Anonymous Coward · · Score: 0

    If Microsoft wanted to win all they would have to do is submit a little big of the win2k code. But they are not open source because that is one award they do not want to win. Of course, only a small portion of the code would be needed because its bloat is greatly known.

  26. Re:Writing Unintelligeable code by Anonymous Coward · · Score: 0

    Java needs to be scrapped. It's NOT compatable across platforms regardless of what SUN's claims are, and besides, Microsoft has pretty much killed it anyway. Face it, we may be able to build our own operating system, but programming languages are and always will be controlled by the biggest software companies.
    Besides, Linux is written in C, so who needs Java. It's an over hyped language for beginning programmers to practice on before they learn how to use pointers.

  27. Re:LISP is readable? by Anonymous Coward · · Score: 0

    wrong wrong wrong. the parentheses are syntactic elements that determine how the actual code is placed in conscells.

  28. Re:Moderation by Anonymous Coward · · Score: 0

    awww, poor baby lost a tiny bit of karma. STFU.

  29. No, no, no... by Anonymous Coward · · Score: 0

    ...its Lots of Infuriating and Silly Parenthesis!

    1. Re:No, no, no... by luge · · Score: 1

      Anyone who thinks that all the true geeks left /. long ago should take a look at this thread :)
      ~luge

      --

      IAAL,BIANLY

    2. Re:No, no, no... by noom · · Score: 1

      Lots of Iritating, Superfluous Parenthesis!

  30. choice of icon by Anonymous Coward · · Score: 0

    Um, shouldn't this story have the "Laugh, it's funny" foot icon?

  31. WOW! WOW by Anonymous Coward · · Score: 0

    What kan eye say! U R 31337 Pascal d00d.

  32. Slow? by Anonymous Coward · · Score: 0

    Is that site hosted on an ISDN? Mirror anyone?

    1. Re:Slow? by Anonymous Coward · · Score: 0

      11 plaidworks.dsl.batnet.com (209.239.163.98) 82.535 ms 87.740 ms 84.028 ms Lame.

  33. Re:Shortest Self Duplicating C program by Anonymous Coward · · Score: 0

    Shortness doesn't matter in a quine. Once you understand how to do a quine, the trick is to make one that's nicely formatted, and doesn't rely on ambiguous casting from integers to chars.

  34. Re:www.ioccc.org by Anonymous Coward · · Score: 0

    I can tell you've never done any game or DSP programming.

    Of course, in the game area, this is slowly changing, thanks mainly to 3d cards.

  35. Re:New contest by Anonymous Coward · · Score: 0

    Intercal has NOTHING on befunge. do a web search, and FEAR!

  36. Re:NVidia Drivers will win :) by Anonymous Coward · · Score: 0

    the code is very easy to read. Just impossible to tell what all the magic numbers do. Control flow is quite clear. Take a look at some of the entries--line noise in a 80x24 square that somehow actually compiles and runs.

  37. Re:first by Anonymous Coward · · Score: 0

    My brain did a conversion on this to Confiscated C code. With all the talk of dvd and eccryption the last few weeks I'm starting to think that maybe there *should* be a contest for that!

  38. Cool idea ;) by Anonymous Coward · · Score: 0

    I'll buy 10!

  39. Re:Writing Unintelligeable code by Anonymous Coward · · Score: 0

    Java is really better for this sort of thing. C doesn't have the proper garbage collection in place to aloow for TRUE obfuscation. In addition, the C++ code will only work on the platform on which it was written. Which platform are they using for this contest anyway? Probably windows. sheesh. That disqualifies the majority of this group from participating. But I guess your code would be pretty obfuscated with all those win32 calls!
    Its things like this that gave us REAL languages. Since Java is now THE dominant language for application development, how many more of these are there going to be?

  40. Re:Fixes by Anonymous Coward · · Score: 0

    d00my, u missed slash_posted = katz;

    it should be slash_posted = katz@

    ! 3 cheers otherwise! (now 2.5)

  41. Doh! "Preview" ate my < by Anonymous Coward · · Score: 0

    Please moderate the previous away... it dilutes the joke

  42. Re:Writing Unintelligeable code by Anonymous Coward · · Score: 0

    I've never had a problem running Java applets (ie 5) but I'll be damned if I can get C/C++ source code to compile the first time. Besides, who wants to take the time to compile a program when you can just run it anywhere. C/BHPL is an evolutionary dead end. It's time it became extinct.

  43. Re:first by Anonymous Coward · · Score: 0
    One of the great lies of the 20th century was that C doesn't support polymorphism.

    Uh... you've gotta get out more often :)

  44. Re:C by Anonymous Coward · · Score: 0

    bash$ make it work! make: *** No rule to make target `it'. Stop.

  45. C.O.B.O.L :-) by Anonymous Coward · · Score: 0
    Completely Obfuscated broken, Obselete Language

    I have not signed in to avoid bad Karma :-)

  46. Re:Au Contraire! by Anonymous Coward · · Score: 0

    This is an old and tired argument that has relatively little merit. Sure, you can do OO programming in C, you can also do it in assembly language. The point is that if you become familiar with C++ then you can do OO programming in C++ more easily, portably, and maintainably than you can in C.

  47. Re:first by Anonymous Coward · · Score: 0

    oh please. object orientation is the wave of the future. everyone uses cout nowadays.

  48. Hey! by Signal+11 · · Score: 0
    Hey, I represent the Martians in this regard, and considering all the junk you guys have been throwing over here that our scientists have been dissecting, I must say that your code is unreadable even to martians!

    ~

  49. NVidia Drivers will win :) by Yohahn · · Score: 0

    Why dosen't somebody submit the NVidia drivers that were given to the XFree86 people.. from what I hear they might just win! :)

  50. Re:This is flamebait, but what the hell... by Anonymous Coward · · Score: 1

    Actually, this year the Obfuscated Perl contest is being sponsored by the Department of Redundancy Department...

  51. That's not an obfuscated C entry... by Anonymous Coward · · Score: 1

    ...that's KNF!

  52. C by Anonymous Coward · · Score: 1

    C Code C Code run C Code not run? C Code RUN! RUN Damnit RUN!

    1. Re:C by QZS4 · · Score: 1

      The way I've seen it is
      "C program run
      C program crash
      C programmer cry"...

      This is the standard behaviour in my empiric tests, anyway.

    2. Re:C by King+of+Noth · · Score: 1

      I do believe the bumper sticker goes: C Code C Code Run Run Code Run Damnit Code I said Run!! at least on the sticker I've seen

      --
      The Law of Identity: Something is what it is.
  53. First OO-Perl Post! by Anonymous Coward · · Score: 1

    #!/usr/bin/perl

    use Slashdot;

    $sd = Slashdot->new();

    if ($topic = $sd->newTopic() && ($topic->postCount() newPost('First', "First Post!\n", 'POT', 'nopreview');

    die "Nyahhh! Server overloaded!\n" unless ($myPost);
    }
    else {
    die "Someone beat you to it!\n";
    }

  54. Re:Obfuscated PERL contest? by Anonymous Coward · · Score: 1

    What they ought to do is have an UNobfuscated perl contest.

  55. Obfuscated C contest submission by Anonymous Coward · · Score: 1

    I remember one of my profs from college threatening to send my assignments in for this contest. He said I had a fair shot at winning.

  56. Re:From the official rules by Mark+J+Tilford · · Score: 1

    Well, frequently people will write their code to make it into a picture of some sort; one person wrote an English->Pig Latin translator shaped like a pig. Another person wrote a program that would input text, and then flip it along the diagonal, and formatted the program so that it could pass through itself unchanged. In another program, (spinellis) the bulk of the text was whitespace, and ... well, run it yourself.
    -----------

    --
    -----------
    100% pure freak
  57. Re:www.ioccc.org by David+Greene · · Score: 1
    I know that this next line we incite a few people but LET THE COMPILER OPTIMISE FOR YOU.

    More to the point: Don't do any "optimizations" that screw things up for the compiler!

    Please do reorganize your algorithms at the high level (using hashes instead of lists, for example).

    Please don't perform your own common-subexpression-elimination and loop induction variable transformations. You are wasting your time and will probably only make things worse.

    --

    --

  58. Re:For All You Young Bucks by pb · · Score: 1

    That's APL. It looks like line noise, with lots of functions implemented with letters that aren't on your keyboard. Sounds greek to you? It could be APL.

    PL/1 worked really hard to try to get you to make a valid program. Apparently some variants would try to autocorrect your code to a valid program, usually failing or generating weird code in the process of doing so.
    ---
    pb Reply or e-mail; don't vaguely moderate.

    --
    pb Reply or e-mail; don't vaguely moderate.
  59. Re:useful C obfuscation by Phil+Gregory · · Score: 1

    I recall liking the one (no link, because I can't get through at the moment) that would ROT13 and/or reverse chunks of text, and would itself compile and work after having been ROT13ed and/or reversed.


    --Phil (Sadly, I'm not twisted enough to submit anything creative enough to win...)

    --
    355/113 -- Not the famous irrational number PI, but an incredible simulation!
  60. Re:first by Scott+Wood · · Score: 1
    And far more importantly, they should return something other than void.

    --

  61. Re:first by Scott+Wood · · Score: 1
    No, everyone does not use cout.

    And it's perfectly easy (and quite common) to be object oriented without cout, and to not be object oriented with cout.

    --

  62. Re:From the official rules by Scott+Wood · · Score: 1
    IIRC that rule was added to encourage people to format their code in "interesting" ways (like one of last years winners that was a flight sim with the code formatted as an airplane, or the one from a while back which was a circle and calculated PI by reading its own source), rather than one big blob.

    --

  63. Re:forget obfuscated C by jd · · Score: 1
    I suggest adding the following entries to your /etc/ld.so.conf:

    /usr/strangeSubstances/California/lib
    /usr/darkAges/trialByCombat/lib
    /usr/local/Kansas/Evolution
    /usr/local/Confederacy
    /opt/darkFuture/Shadowrun
    /opt/darkFuture/Gibson/Neuromancer
    /opt/money/bookRights
    /opt/money/tvShows
    /opt/money/large/backHander
    /mnt/Government/Power/corporateMight

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  64. Microsoft Windows by krynos · · Score: 1

    If M$ would publish the source of Windows, they would surely won... Some unintelligible code that compile and run (sort of)...

  65. Re:first by KnightStalker · · Score: 1

    I knew I missed something. This is why I never write code before noon. :-)

    --
    * And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
  66. Re:first by KnightStalker · · Score: 1

    typedef void (FNPTR)();

    typedef struct {
    FNPTR first;
    } STRUCT;

    void bob() {
    return 1;
    }

    int main(void) {
    STRUCT post;
    post.first = bob;
    if (post.first()) { printf("FIRST POST!!!"); }
    }

    /* that's C my friend. */

    --
    * And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
  67. Re:first by KnightStalker · · Score: 1

    ... er, actually, bob() and FNPTR() should accept (void) as parameters, not (). Please excuse my gross faux paux. :-)

    --
    * And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
  68. Re:Au Contraire! by KnightStalker · · Score: 1

    I like the way you think!

    --
    * And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
  69. Re:first by KnightStalker · · Score: 1

    ... er, and void functions hardly ever return 1. Damn, I'm on a roll :-)

    --
    * And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
  70. Re:first by KnightStalker · · Score: 1

    Would that be "Effective C++", by Scott Meyers? :-)

    --
    * And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
  71. Call me paranoid,but the octal was disturbing by Derek+Pomery · · Score: 1

    so I checked...

    perl -e '@a=;foreach(@a){foreach(split(/,/,$_)){print chr(oct);}}'

    Hm. A self-replicating program. Well, at least the rest isn't obfuscated.

    --
    -- perl -e'print pack"H*","6e656d6f406d38792e6f7267"' /. ate my old sig. Bastards.
    1. Re:Call me paranoid,but the octal was disturbing by MbM · · Score: 1

      Yeah, it's based on self replication. I rewrote part of the code to use octal before I posted it just to mess with people, instead it caused a bug in the program after a few iterations. Email me if you want the corrected version (I see no need to repost it again)
      - MbM

      --
      - MbM
  72. useful C obfuscation by NightStriker · · Score: 1

    Searching through the archive some time ago I found a program that actually did something neat. It would take as input a text file and output that file in braille, using stars for the dots. The fun part, though, was decoding it. I essentially went through and replaced the #defines with readable pnemonics, then reformatted the thing so it looked like normal C (if there is such a thing).

    1. Re:useful C obfuscation by / · · Score: 1

      com0prise (kõm-prhz2) tr.v. com0prised, com0pris0ing, com0pris0es.
      1. To consist of; be composed of.
      2. To include; contain.

      That looks like what I intended to say.

      --
      "If one is really a superior person, the fact is likely to leak out without too much assistance" -- John Andrew Holmes
    2. Re:useful C obfuscation by David+Gould · · Score: 2


      Actually, a lot of them are useful programs, either original ones or re-implementations of standard utilities, but with absolutely horrifying things done in the code. Ideally, the obfuscations are not just there for puzzle value, but actually serve to optimize performance.

      I wish I could come up with some stuff like this -- I have a few programs that I've written normally, but with some moderately funky techniques, that I've been thinking I might be able to obfuscatify into reasonable entries, but I'm unlikely to get them ready in time. One of these years...


      David Gould

      --
      David Gould
      main(i){putchar(340056100>>(i-1)*5&31|!!(i<6)<< 6)&&main(++i);}
    3. Re:useful C obfuscation by seebs · · Score: 2

      >being itself an ascii pig comprised of >pig-latin'ed code.

      "comprising" or "composed of".

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
    4. Re:useful C obfuscation by / · · Score: 2

      The code in question (I assume) is this lovely slashdotted ditty over here in case anyone wants a look-see.

      My favorite still has to be this one which translates the imput into pig latin while being itself an ascii pig comprised of pig-latin'ed code. I'd inline it, but slashdot munges the extra spacing.

      --
      "If one is really a superior person, the fact is likely to leak out without too much assistance" -- John Andrew Holmes
  73. Re:first by mikpos · · Score: 1

    OK good thing you caught some of your errors before I did, or you'd have had a real schooling :). However, you still have a gross error: structs can contain pointers to functions, not functions. Corrected code would look like so:

    #include <stdio.h>
    int true(void) { return 1; }
    int
    main(void)
    {
    struct { int (*first)(void) } post = {true};
    if (post.first()) printf("first post :(\n");
    } // taking advantage of new C99 rules, woo

  74. Re:first by mikpos · · Score: 1

    Either Scott Meyers is describing C++ or he's incompetent. A function prototype with an empty parameter list is not an ANSI function declaration.

  75. they're going about it all wrong by mikpos · · Score: 1

    If you want obfuscated code, all you have to do is go down to your local high school and look at the code the students are writing in their introductory classes. Funny, they usually teach comments on the first day, but no one seems to figure them out until at least their second year :). Oh wait, you wanted correct code? Well maybe the local high school isn't such a hot idea after all.

  76. Re:first by mikpos · · Score: 1

    oops ya, i caught that after i posted it. oh well.

  77. Re:Writing Unintelligeable code by mikpos · · Score: 1

    No, the C++ binary will only run on the platform it was written on. This is no different from any other compiled language. Java is no exception is the rule; Java will only run on a Java platform. In fact Java seems to be worse since it never does work the same on all platforms ("all platforms" being 3 platforms according to Sun, though). Unix and C were developed with portability in mind, but source compatibility, not binary compatibility.

  78. And the winner gets ... by Pretor · · Score: 1

    A job at Nvidia.

  79. Re:www.ioccc.org by osu-neko · · Score: 1
    Actually, no. If it's time critical, it should *NOT* be in assembly, in all probability, because the chances are that the compiler will outsmart you or the chip will change.

    If the chip changes in a way that makes your optimization suddenly less optimal, it makes no difference if the now less optimal machine code was generated by hand-coded assembly or by the C compiler. If you're trying to make some claim about what happens when you recompile the code, then you're missing the point of time critical code. If it's time critical, and I get a new processor that allows me to make it faster, rest assured I'll do so. Why sit around waiting for my compiler to be upgraded to be able to optimize for the new processor when I can do it right away?

    <I>Assembly is like saying "Moore's Law doesn't apply to me".</I>

    Err, huh? Sure, faster processors will eventually make my code faster without my needing to optimize it. If that's the case, why worry about optimizing at all?

    I was talking specifically about time-critical code, where I'm trying to get every ounce of speed out I can. Moore's Law doesn't enter into it. I want it to be as fast as it can be <I>today</I>!

    <I>Take your pick: Hand-optimized Pentium assembly, or EGCS code tuned for the Pentium II. :)</I>

    Oooh look, it's everyone's favorite logical falacy, the false dilemma. Why would I choose either of these two when hand-optimized Pentium II assembly would beat both?

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  80. Re:Anti-Obfuscated C by osu-neko · · Score: 1
    Cute, but in Pascal, strings are delimited by ', not ", IIRC.

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  81. Gratuituous semicolons... by osu-neko · · Score: 1
    I still say a semicolon should be unnecessary after the last statement in a block. This is one of the few things Pascal had right!

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
    1. Re:Gratuituous semicolons... by osu-neko · · Score: 1
      Pascal semicolon use is consistent! In Pascal, a semicolon is a statement separator, not a statement terminator. You consistently put semicolons between statements.

      --

      --
      "Convictions are more dangerous enemies of truth than lies."
    2. Re:Gratuituous semicolons... by lintux · · Score: 1

      No, that's more something Pascal should have done right... You have to be consistent, I think. Things like that might only be confusing, especially when a semicolon that is present generates an error.

  82. Re:Au Contraire! by osu-neko · · Score: 1
    Well, that was obviously a contrived example, but the techniquie you're using can help make C code more maintainable. Develop on the idea you're exploiting, and you'll see the only real advantage of C++ is that it offers multiple inheritance, where when writing object oriented C code, only single inheritance is possible (without going through contortions).

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  83. Re:first by osu-neko · · Score: 1
    ... er, and void functions hardly ever return 1. Damn, I'm on a roll :-)

    These errors are perfectly understandable. I've frequently noted that I'll type into web edit boxes or email bits of code I would NEVER type if I were actually entering real code into Emacs. I don't know why. I suspect I'm not perfectly modeless -- my C-mode syntax checker only functions while Emacs is also in C-mode.

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  84. Re:pascal rocks! by osu-neko · · Score: 1
    not quite as nice as Smalltalk

    Err, umm, err. Oh, never mind. I could say something unkind about the readability of Smalltalk, but I know there are people who say the same about Lisp, the single most readable, understandable, and beautiful language ever made. So I'll keep my mouth shut.

    I find it interesting that you still like your first language. I hate mine. But then, my first language was BASIC...

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  85. Re:www.ioccc.org by osu-neko · · Score: 1
    LET THE COMPILER OPTIMISE FOR YOU

    I don't know if I'd go that far. I would say don't worry about optimizing non-critical code. As for the critical parts, if it's that time-critical, it should probably be in assembly language.

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  86. Re:first by osu-neko · · Score: 1
    if (post.first()) { printf "FIRST POST!" }

    Bzzzzzzzzzzzzzz

    thats C++ my friend.

    You got a compile error!


    Why do you say that's C++? Because of the "post.first()"? That's perfectly legal in C, assuming "post" is a structure that contains an element named "first" which is a function pointer.

    One of the great lies of the 20th century was that C doesn't support polymorphism. Absolutely untrue.

    Of course, he will get a compile error, but only due for calling printf with no parentheses.

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  87. Re:Au Contraire! by osu-neko · · Score: 1
    Stuff like polymorphism is a lot cleaner syntactically in C++ than in C.

    I don't see how. I'd say the nice thing C++ gives you is true constructors (instead of having to roll your own), and it's nice how it automatically pushes the object pointer on the stack rather than having to explicitly declare a "this" parameter to your methods. Multiple inheritance is the third advantage. Beyond these, C++ has no real advantages over C for object oriented programming. And the first two of these are simply syntactic sugar.

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  88. Re:This is flamebait, but what the hell... by osu-neko · · Score: 1
    Yeah, writing obfuscated Perl is too easy. Perl code is often indistinguishable from line noise.

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
  89. I vote for procmail! by Colin+Smith · · Score: 1

    goto
    goto
    goto



    AAAAaahhhh!

    --
    Deleted
  90. Re:Anti-Obfuscated C by Skim123 · · Score: 1
    Cute, but in Pascal, strings are delimited by ', not "

    Hehe, knew I'd make a mistake somewhere! It's been over four years since I've typed in the Ctrl-F9 combination to have my Borland TurboPascal compiler compile away! :) Ah, I miss those days. Pascal is a good mix of C and BASIC. It's both powerful and readable.

    C is cool
    BASIC is easy
    Pascal is for those who like to make comprimises
    COBOL is for those who like to type a lot

    --

    I could not justify my existence if I were a turkey farmer. Would I terminate myself? Undoubtably, yes.

  91. Anti-Obfuscated C by Skim123 · · Score: 1

    #define begin {
    #define end }
    #define procedure void
    #define writeln printf


    procedure main()
    begin
    writeln("Pascal is easy to read!");
    writeln("Although boring to write.");
    end

    --

    I could not justify my existence if I were a turkey farmer. Would I terminate myself? Undoubtably, yes.

    1. Re:Anti-Obfuscated C by seebs · · Score: 2

      Also incorrect.

      MAIN RETURNS INT YOU SIMPERING FOOLS!

      :)

      (No, really, it does. "void main" is Just Plain Wrong.)

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  92. Re:Single entries to multiple contests? by reg · · Score: 1

    You mean something like this: From: drs@netcom.com (Data Rentals and Sales) Subject: Re: Please help me translate this to... Keywords: COBOL C translate help plea Date: Mon, 30 Aug 1993 18:28:59 GMT In article rstout@netcom.com (Rick Stout) writes: >...and for my chapter on >programming languages I need examples of a simple program in >each of the most common languages. > >Well, I had no problem with C and C++ (being a C programmer trying >to learn C++). People from other comp.lang groups helped me with >Pascal, FORTRAN, and BASIC, but as I said, nobody reads alt.cobol. If you want a sample program in multiple languages, try this one: ----------------8_$$; echo "hello polyglots"; rm _$$; exit print C stop run. -*, 'hello polyglots' C C print. C display "hello polyglots". ( C */ int i; /* C */ main () { /* C */ i=printf ("hello polyglots\n"); /* C *) (* C *) begin (* C *) writeln ('hello polyglots'); (* C *) (* ) C * ) pop 60 360 ( C * ) pop moveto (hello polyglots) show ( C * ) pop showpage (( C *) end .(* ) C)pop% program polyglot. *){*/} ----------------8 _ Kevin D Quitt 96.37% of all statistics are made up

  93. Re:Moderation by trog · · Score: 1

    thats an easy one

    Shut The Fuvk Up.

    I'm telling you...kids these days...

  94. obscufiated enough? by MbM · · Score: 1

    example obscufiated program
    --cut here--
    char s[]={0060,0175,0073,0040,0155,0141,0151,0156,0050, 0151,0156,0164,0040,0141,0162,0147,0143, 0054,0143,0150,0141,0162,0052,0052,0141,0162,0147, 0166,0051,0173,0151,0156,0164,0040,0170, 0075,0060,0073,0151,0146,0050,0141,0162,0147,0143, 0076,0061,0051,0173,0151,0146,0050,0041, 0163,0164,0162,0143,0155,0160,0050,0141,0162,0147, 0166,0133,0061,0135,0054,0042,0141,0163, 0144,0146,0042,0051,0051,0173,0160,0162,0151,0156, 0164,0146,0050,0042,0151,0156,0164,0040, 0171,0075,0045,0144,0073,0134,0156,0143,0150,0141, 0162,0052,0141,0133,0135,0075,0173,0042, 0054,0171,0053,0061,0051,0073,0146,0157,0162,0050, 0073,0170,0074,0050,0171,0052,0062,0051, 0073,0170,0053,0053,0051,0160,0162,0151,0156,0164, 0146,0050,0042,0134,0042,0045,0163,0134, 0042,0054,0042,0054,0141,0133,0170,0135,0051,0073, 0160,0162,0151,0156,0164,0146,0050,0042, 0134,0042,0045,0163,0134,0042,0054,0134,0042,0045, 0163,0134,0042,0175,0073,0134,0156,0143, 0150,0141,0162,0040,0163,0133,0135,0075,0173,0042, 0054,0141,0162,0147,0166,0133,0062,0135, 0054,0141,0162,0147,0166,0133,0063,0135,0051,0073, 0146,0157,0162,0050,0170,0075,0060,0073, 0163,0133,0170,0135,0073,0170,0053,0053,0051,0160, 0162,0151,0156,0164,0146,0050,0042,0045, 0060,0063,0157,0054,0042,0054,0163,0133,0170,0135, 0051,0073,0160,0162,0151,0156,0164,0146, 0050,0042,0045,0163,0134,0156,0042,0054,0163,0051, 0073,0175,0145,0154,0163,0145,0173,0151, 0146,0050,0141,0162,0147,0143,0076,0062,0051,0173, 0052,0163,0075,0155,0141,0154,0154,0157, 0143,0050,0070,0061,0071,0062,0060,0051,0073,0163, 0160,0162,0151,0156,0164,0146,0050,0163, 0054,0042,0045,0163,0040,0141,0163,0144,0146,0040, 0134,0042,0045,0163,0134,0042,0040,0134, 0042,0045,0163,0134,0042,0076,0045,0163,0056,0143, 0073,0147,0143,0143,0040,0045,0163,0056, 0143,0040,0055,0157,0040,0045,0163,0073,0162,0155, 0040,0045,0163,0056,0143,0042,0054,0141, 0162,0147,0166,0133,0060,0135,0054,0141,0162,0147, 0166,0133,0061,0135,0054,0141,0162,0147, 0166,0133,0062,0135,0054,0141,0162,0147,0166,0133, 0060,0135,0054,0141,0162,0147,0166,0133, 0060,0135,0054,0141,0162,0147,0166,0133,0060,0135, 0054,0141,0162,0147,0166,0133,0060,0135, 0051,0073,0163,0171,0163,0164,0145,0155,0050,0163, 0051,0073,0175,0040,0145,0154,0163,0145, 0173,0146,0157,0162,0050,0073,0170,0074,0171,0073, 0170,0053,0053,0051,0151,0146,0050,0041, 0163,0164,0162,0143,0155,0160,0050,0141,0133,0170, 0052,0062,0135,0054,0141,0162,0147,0166, 0133,0061,0135,0051,0051,0040,0160,0162,0151,0156, 0164,0146,0050,0042,0133,0045,0163,0135, 0040,0045,0163,0134,0156,0042,0054,0141,0133,0170, 0052,0062,0135,0054,0141,0133,0170,0052, 0062,0053,0061,0135,0051,0073,0175,0175,0175,0145, 0154,0163,0145,0040,0160,0162,0151,0156, 0164,0146,0050,0042,0045,0163,0040,0153,0145,0171, 0167,0157,0162,0144,0040,0133,0134,0042, 0144,0145,0146,0151,0156,0151,0164,0151,0157,0156, 0134,0042,0135,0134,0156,0155,0142,0155, 0100,0154,0151,0156,0165,0170,0056,0143,0157,0155, 0134,0156,0042,0054,0141,0162,0147,0166, 0133,0060,0135,0051,0073,0175,0000,0045,0163,0040, 0164,0145,0163,0164,0040,0134,0042,0045, 0163,0134,0042,0040,0134,0042,0045,0163,0134,0042, 0076,0045,0163,0056,0143,0073,0147,0143, 0143,0040,0045,0163,0056,0143,0040,0055,0157,0040, 0045,0163,0073,0162,0155,0040,0045,0163, 0056,0143,0000};
    main (int argc, char ** argv) {
    char *y=s;
    if(argc>1) {
    if (!strcmp(argv[1],"test")) {
    printf("int y=1;\nchar*a[]={\"email\",\"mbm@linux.com\"};\ncha r s[]={");
    while(y[0]) printf("%03o,",*y++);
    printf("%s\n",s);
    }
    } else {
    *s=malloc(512);
    sprintf(s,s+582,argv[0],argv[0],argv[0],argv[0],ar gv[0],argv[0],argv[0]);
    system(s);
    }
    }
    --cut--
    *hint* run this program atleast twice
    - MbM

    --
    - MbM
  95. Re:Fixes by doomy · · Score: 1

    No one is perfect :)

    Actually slash_posted should have been set to tacocmdr which is a define equal to 0 ;)
    --

    --
    ...free your source and the rest would follow...
  96. Re:Shortest Self Duplicating C program by ruud · · Score: 1

    I remember hearing about a contest to write the shortest self-duplicating C program (i.e. something that would spit out an exact copy of its own code). Someone submitted an empty file once, which is kind clever. But does anyone know of the next shortest?

    Actually, the empty program is not a valid C program according to the ISO / ANSI definitions. For one thing, it doesn't define main() and so will produce a linker error.

    The only other one I off hand know is the one mentioned in the comp.lang.c FAQ


    --
    --
    bgphints - internet routing news, hints and ti
  97. Re:first by ruud · · Score: 1

    A function prototype with an empty parameter list is not an ANSI function declaration.

    Actually, it is a function declaration, just not a prototype.


    --
    --
    bgphints - internet routing news, hints and ti
  98. NVidia Drivers will win :) by Yohahn · · Score: 1

    Why dosen't somebody submit the NVidia drivers that we given to the XFree86 people.. from what I hear they might just win! :)

  99. Re:first by N1KO · · Score: 1

    /* What if? */
    #define printf printf (
    #define "FIRST POST!" "FIRST POST!\n")
    #define } }; /* not sure if this works */
    /* Obfuscated enough? */

  100. Re:From the official rules by Eric_Scheirer · · Score: 1

    So that your program can be interestingly formatted, like this one.

  101. pascal rocks! by Jose · · Score: 1

    whad'ya mean "few things"?!! Pascal rocked!! It was my first language...man was it sweet! It reads a hell of a lot nicer than C/C++ and java, not quite as nice as Smalltalk, but now we're talking about way different leagues here.

    And interfaces, come-on, borland TP 7 has to be the best UI I've ever seen..well again, smalltalk express by parkplace digitalk (I think) again takes the cake.

    --
    The basic sleazeware produced in a drunken fury by a bunch of UCBerkeley grad students was still the core of BIND. --PV
  102. Re:Shortest Self Duplicating C program by rebrane · · Score: 1
    It's hard to do a short quine which is also strictly-conforming.

    No it's not.

    #include <stdio.h>
    char*f="#include <stdio.h>
    char*f=%c%s%c;int main()
    {printf(f,34,f,34,10); return 0; }%c";int main()
    {printf(f,34,f,34,10); return 0; }

    Try it out. gcc -Wall doesn't give any warnings and it works like a dre am.

    --neil

  103. Re:Au Contraire! by Shadowlion · · Score: 1

    Where would I go to learn more about object-oriented C programming?

  104. Re:google by QuMa · · Score: 1

    Hmmm, slightly outdated:

    How can I enter the contest?


    Sorry, right now you cannot enter the contest. The International Obfuscated C Code Contest is closed.

    Even though you missed last year's contest, please consider entering the next contest! While you should want for the new rules before sending in an entry, you
    can get an idea of what to expect by reading the old rules and the old guidelines.

  105. Re:Writing Unintelligeable code by aphrael · · Score: 1

    I believe that's one of the most frightening concepts i've ever seen in software design.

    Yikes!

  106. Re:Single entries to multiple contests? by double_h · · Score: 1

    It would be interesting to see a single valid entry that could be submitted to more than one Obfuscated Foo Code Contest

    There was an entry in the Obfuscated C contest a few years ago that was a Hello World program that ran in C, Bourne Shell, and Pascal (i.e. the same block of code could be parsed successfully in all three environments). It made creative use of comment characters so that each language would ignore those statements meant for the other two.

  107. Re:Single entries to multiple contests? by meldroc · · Score: 1

    In the Perl Journal there is an entry in the Obfuscated Perl Contest that compiles in both Perl and C. It was said that this program caused one of the judges to run to the bathroom to wash his hands compulsively. ;) I'm wondering if the author's going to enter that program into the IOCCC.

    --

    Meldroc, Waster of Electrons
  108. This is flamebait, but what the hell... by Rombuu · · Score: 1

    When is the obfuscated PERL contest?

    Oh wait, it pretty much all looks that way...

    --

    DrLunch.com The site that tells you what's for lunch!
    1. Re:This is flamebait, but what the hell... by KrAphtd1nN3r · · Score: 1

      There is an obfuscated Perl code contest. The rules and necessary information are published in the Perl journal every year, if I'm not mistaken!

      And although Perl does look obfuscated right from the start, it is truly horrible to see some obfuscated Perl!!!

      --
      "Code free or die!"
    2. Re:This is flamebait, but what the hell... by droob · · Score: 1
      Actually, this year the Obfuscated Perl contest is being sponsored by the Department of Redundancy Department...
      ...and the Natural Guard.
  109. Hehehe... by Zarniwoop · · Score: 1

    perhaps I should enter some of my code from my "Intro to C" class. What can I say, I didn't know what I was doing at that point, and the ONLY thing that saved me was Emacs having auto-indent.

    Its never good when you can go back to a program a month later, stare at it for a mintute, and still be wondering what it does...

    --
    Still not dead.
  110. Tax code. by tiny69 · · Score: 1

    Would I get credit for winning if I posted the US Tax Code?

    --
    Go not unto/. for advice, for you will be told both yea and nay (but have nothing to do with the question)
  111. Re:Not really possible by nhowie · · Score: 1

    COBOL is just too verbose a language to obfuscate in the way you can obfuscate C.

    That was kinda the point. most of the programmers that I know who use both languages would prefer to debug 20 year old COBOL than 8 year old C.

    But I bet all of them (the sane ones anyway) would rather write something new with C. COBOL is a hideous language, on a par with Visual Basic ;)
    --

  112. Re:For All You Young Bucks by nhowie · · Score: 1

    I can't wait to read the entries in the obfuscated COBOL code contest ...
    --

  113. LISP is readable? by EnderWiggnz · · Score: 1

    (L)iberal (i)ndentation (s)paces (p)arenthesis come on... anything that generally uses more parentheses than code is not exactly easy on the eye... though to each his own...

    --
    ... hi bingo ...
    1. Re:LISP is readable? by CmdrPinkTaco · · Score: 1

      Lots Of Insepid(SP?) Parenthesis
      ------------------------------------- -------

      --
      Please give your mod points to others, Im at the cap. They will appreciate it more
    2. Re:LISP is readable? by Daniel · · Score: 2

      No, no, no, you're missing the point. The parentheses are *part of* the code!

      Daniel

      --
      Hurry up and jump on the individualist bandwagon!
  114. Re:Writing Unintelligeable code by slashdot-me · · Score: 1

    The contest is on unix, naturally. It's been running annually (almost) since 1984.

    Ryan Salsbury

  115. Re:Shortest Self Duplicating C program by prizog · · Score: 1

    #include
    void main(){FILE *f=fopen("q","r");while(!feof(f)){printf("%c",fget c(f))};}

    Save this file as q

  116. Re:www.ioccc.org by GoofyBoy · · Score: 1


    >Some will elicit reactions of abject terror!

    The first time I heard about the contest I was just beginning in university. I after seeing some of the enteries then I swore off programming in C.

    These contests are just plain sick. :)


    --
    The surprise isn't how often we make bad choices; the surprise is how seldom they defeat us.
  117. Last year's contest has some beautiful entries... by Simon+Brooke · · Score: 1
    Some people are really too clever. Among last year's entries try out banks.c - it is truly elegant... Never mind the obfuscation, to produce code that tight is just awsome.

    But the one which had me falling off my seat giggling was this!

    --
    I'm old enough to remember when discussions on Slashdot were well informed.
  118. Re:IOCCC is just a front for a secret plot! by snookums · · Score: 1

    Nah. Everybody knows that all Microsoft products are written in basic. Bill wrote that basic for the Altair all those years ago, and has been building on the same code ever since.

    DOS was written in GWBASIC;
    Win 3.x in QBASIC;
    WinNT in VB;
    Win95 in VBScript; and
    Win2K is a fat activeX control running inside IE5

    --
    Be careful. People in masks cannot be trusted.
  119. For the lexiconically challenged... by moist · · Score: 1
    To save you the effort of picking up a dictionary...

    From Websters(tm),

    obfuscate: To make so confused or opaque as to be difficult to perceive or understand: "A great effort was made . . . to obscure or obfuscate the truth" (Robert Conquest).

  120. Re:For All You Young Bucks by TheTomcat · · Score: 1

    I can see it now "The Grande Olde Obfuscated FORTRAN Code Contest"

    The GOOF Code Contest?

  121. Re:Moderation by Old+Wolf · · Score: 1

    I always thought it was shorthand for STUFF YOU

    oh well

    now, my main point is, why did that totally redundant, pedantic and lame message about 16:19 and 16:18 get "2, Informative" ? It wasn't informative at all. Or was the moderator feeling guilty about the "0, Redundant" and decided to make up for it?

  122. Re:Writing Unintelligeable code by Old+Wolf · · Score: 1

    You can write a C++ file on windows, then copy it to a unix system and compile and run it. Then the binary runs on unix but the source was written on windows. Or you can go even further and use a windows->unix cross-compiler.

    (PS. No pedantic comments like "you lamer you mean intel->sun or whatever" please, my meaning should be clear)

  123. Re:New contest by Rocky · · Score: 1

    Or how about an even better idea:

    A non-obfuscated Intercal contest!
    Try to write as clear a program as possible.

    Now that would be a challenge...

    --
    "I'm an old-fashioned type of guy. I worship the Sun and Moon as gods. And fear them."
  124. Re:One of my favorites... by Zooks! · · Score: 1

    This one can't be a winner, because sending it through the preprocessor has almost unobfuscated it enough to make it readable. I've played a little tetris program somebody made that was practically immune to analysis other than to the compiler :-)

    Here's a ansified and more simplified version of the code that compiles. I think there was a bug in the preprocessing on the lines that are commented out in main. It still runs a simple program, though.

    Due to slashdot's wacko html, tabs are missing and I can't put in the includes for stdio.h and stddef.h. (Yes, I'm sure there's a way to do it but I'm lazy)

    Enjoy:

    int *C,E[999],L[999],M[999],P[999],l,i,j;
    char B[999],F[2];

    char *m[12*999],*p,*q,*x,*y,*z,*s,*d,*f;

    char *Q(char *s, char *o)
    {
    for(x=s; *x; x++)
    {
    for(y=x,z=o;*z&&*y==*z;y++)
    {
    z++;
    }

    if(z>o&&!*z)
    {
    return x;
    }
    }

    return 0;
    }

    int main(void)
    {
    m[11*999]="E";
    while(puts("OK"),gets(B))
    {
    switch(*B)
    {
    case 'R':
    C=E;
    l=1;
    for(i=0;i" ))*p++= '#' ,*p=' ' ;
    while(p=Q(s, "=" ))*p++= '!' ,*p=' ' ;
    }
    d=B;
    while(*F=*s)
    {
    //*s=='"'& ;
    //&j++;
    if(j&1||!Q(" \t",F))*d++=*s;
    s++;
    }
    *d--=j=0;
    if(B[1]!='=')
    {
    switch(*B)
    {
    case 'E':
    l=-1;
    break ;
    case'R':
    B[2]!='M'&&(l=*--C);
    break;
    case '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));
    break;
    case 'P':
    B[5]=='"'?*d=0,puts(B+6):(p=B+5,printf("%d\n",S()) );
    break;
    case 'G':
    p=B+4,B[2]=='S'&&(*C++=l,p++),l=S()-1 ;
    break;
    case 'F':
    {
    *(q=Q(B,"TO"))=0;
    p=B+5;
    P[i=B[3]]=S();
    p=q+2;
    M[i]=S();
    L[i]=l ;
    }
    break;
    case 'N':++P[*d]':
    return o > J();
    default:
    p--;
    return o;
    }
    }

    int K(void)
    {
    int o=V();
    switch(*p++)
    {
    case '$':
    return o = K();
    default:
    p--;
    return o;
    }
    }

    int V(void)
    {
    int o=W();
    switch(*p++)
    {
    case '+':
    return o + V();
    case '-':
    return o - V();
    default:
    p--;
    return o;
    }
    }

    int W(void)
    {
    int o=Y();
    switch(*p++)
    {
    case '*':
    return o * W();
    case '/':
    return o / W();
    default:
    p--;
    return o;
    }
    }

    int Y(void)
    {
    int o;
    return *p=='-'?p++,-Y():*p>='0'&&*p='9'?strtol(p,&p,0):*p =='('?p++,o=S(),p++,o:P[*p++];
    }


    --

    --

    "I'm too old to use Emacs." -- Rod MacDonald

  125. Re:For All You Young Bucks by Absimiliard · · Score: 1

    Hmmmmm obfuscated FORTRAN. If I recall correctly that would be ALL code written in FORTRAN woudln't it?

    Absimiliard

  126. Re:first by ucblockhead · · Score: 1

    Oops. Wrong language!

    Oh well. I hardly ever do C these days...

    --
    The cake is a pie
  127. Re:Au Contraire! by ucblockhead · · Score: 1

    In terms of results, yes. In terms of code maintainability, no.

    A trivial example. You can't do this in C:

    for(int i=0;i10;i++)

    Yes, you can translate that to

    int i;
    for(i=0;i10;i++)

    and have something that is semantically the same, but there are code maintainability reasons why you might want the former.

    --
    The cake is a pie
  128. Re:Au Contraire! by ucblockhead · · Score: 1

    Actually, it was more a continuation of the "going to the obfuscated code site to get code for my current project comment". But yeah, you can do some pretty sophisticated OO stuff in C. The encapsulation is difficult to do, though I've had luck with statics and different source files to achieve much the same.

    You can't really get anything like a constructor or destructor, though, which goes a long way towards making C++ maintainable.

    There are also a lot of little non-OO C++ constructs that are underrated. If I were contemplating a straight C project, I'd still use C++ to get a couple of these.

    --
    The cake is a pie
  129. Au Contraire! by ucblockhead · · Score: 1

    Bzzt. That's perfectly legal C. This compiles with gcc just fine and dandy:

    typedef int IntFunc();

    int TheFunc()
    {
    return 1;
    }

    struct st_Post
    {
    IntFunc *First;
    } Post;

    int main()
    {
    Post.First = TheFunc;

    if( Post.First() ) printf("FIRST POST!\n");
    }


    (Function pointers as members of structures are perfectly legal C.)

    Now will you guys stop slashdoting the site? I need to download some code for my latest project.

    --
    The cake is a pie
    1. Re:Au Contraire! by BinxBolling · · Score: 1
      Actually, IIRC, anything you can do in C++ can be done in C. (At least this used to be the case way back when I was writing C++ code) Remember that the first few generations of C++ compilers were actually just preprocessors which translated C++ source code into pure C source, which was then fed to the C compiler.

      Yeah. And anything you can do in either C or C++ you can also do in assembler. Or hey, you could just build a turing machine.

      Question is, would you want to?

      Stuff like polymorphism is a lot cleaner syntactically in C++ than in C.

    2. Re:Au Contraire! by Tassach · · Score: 1
      But yeah, you can do some pretty sophisticated OO stuff in C. The encapsulation is difficult to do, though I've had luck with statics and different source files to achieve much the same.


      Actually, IIRC, anything you can do in C++ can be done in C. (At least this used to be the case way back when I was writing C++ code) Remember that the first few generations of C++ compilers were actually just preprocessors which translated C++ source code into pure C source, which was then fed to the C compiler. Doing C++ -> C conversion via a preprocessor was easy; doing it by hand would be very painful.

      "The axiom 'An honest man has nothing to fear from the police'
      --
      Why is it that the proponents of "one nation under God" are so eager to get rid of "liberty and justice for all"?
    3. Re:Au Contraire! by Logan · · Score: 2
      Check out the source code to GTK (or simply do some GTK programming).

      logan

    4. Re:Au Contraire! by ucblockhead · · Score: 2

      Hey, if I wrote maintainable code, they'd be able to hire someone to replace me.

      --
      The cake is a pie
  130. Re:first by ucblockhead · · Score: 1

    According to the latest Scott Meyers book I got, it is preferable to use empty braces for functions that take no parameters. I can't remember the argument right now, though.

    --
    The cake is a pie
  131. Re:Bah! Even ordinary Perl code puts IOCCC to sham by Uller-RM · · Score: 1

    Nah. APL takes the cake any day.

    Haskell does pretty good too if you don't use parenthesis - here's a nasty one we encountered in class:

    executeTwice f x = f (f x)
    successor x = x + 1

    executeTwice successor 7 = 9
    executeTwice executeTwice successor x = 11
    executeTwice executeTwice executeTwice successor 7 = 23

    Two cents to anyone not well versed in FPs that can trace expansion of the above. =)

  132. Re:WHO CARES WHAT LINUX WAS WRITTEN IN!! by apathetic · · Score: 1

    c'mon scheme is fun... o wait i still have nightmares about it... while working on our final project we pulled some late hours and when we actually slepted we dreamed in scheme, talk about scary

  133. Re:For All You Young Bucks by TheBeard · · Score: 1

    Back when I was learning the trade, and computers ran on vacuum tubes, students from the University of Michigan had to buy their own punch cards and students have always been poor. This lead to the idea that you got as much code on each line of your Fortan as possible to make your supply of cards last. This lead to some really strange code I kid you not.

  134. Re:Writing Unintelligeable code by fprintf · · Score: 1

    Excellent site, but quite honestly I could never tell when the author was serious or kidding. For instance, I use many of the techniques such as using a nested Loop index of i (see #19)legitimately in every day coding.

    Any one wanna hire me? :-)

    --
    This post brought to you by your friendly neighborhood MBA.
  135. Re:www.ioccc.org by astrophysics · · Score: 1

    The compiler may reorder the arithmetic better
    than I, but the compiler won't change the algorithm. When possible, optimizing your algorithm almost always helps. Sometimes it's your only hope at decent performance.

    For example, last year I had code that took several hours for a n=256^3 box. Since it scaled as n^2, and I needed to apply it to a n=1024^3 box, optimization was necessary. By optimizing the algorithm, I got it to run on a n=1024^3 box in less than a 15 minutes. By further optimizing the C (not assembler) I got it to run in less than 25 seconds.

    So I'll happily ignore your suggestion.

  136. Re:first by quakeaddict · · Score: 1

    Bzzzzzzzzzzzzzz

    thats C++ my friend.

    You got a compile error!

    --
    I'm still working on a clever footer.
  137. Re:For All You Young Bucks by pfingst · · Score: 1

    Unfortunately, COBOL is too anal about separators, etc to allow obfuscation. We'll just have to settle for the First Annual COBOL Spaghetti (Code) Dinner!

  138. Re:That was easy :) by kcarnold · · Score: 1

    That's idiot basic. Try this:

    #include <stdio.h>
    void main(){while(1)printf("In reality I'm an obfuscated version of msvcrt.dll");}

    I hope that works right :-)

  139. Re:Moderation by billybob+jr · · Score: 1

    I doubt it was someone trying to make up for it, because they could have just moderated the original.

    However, it is fairly common and easy to assume that as you read farther down the page you are also progressing in time. This is false, and really checking the message number and/or time is the only way to tell. I've seen this pointed out before, but obviously it still needs to be done. Perhaps the moderator thought that more people should see Remote's explanation to prevent it from happening again.

  140. Re:One of my favorites... by Fesh · · Score: 1
    Hehe! Seems to be self-documenting as well...

    Hey Kids! Find the words Obfuscated_C and UNIX in this source fragment!

    Although in my opinion, using defines like that is cheesing it a bit...


    --Fesh

    --
    --Fesh
    Kill -9 'em all, let root@localhost sort 'em out.
  141. Re:Let the IOCCC grade your students! by d-rock · · Score: 1

    Yeah, it's amazing sometimes. One of the guys in my Freshman dorm wrote his final project, a mule clone, with I swear 140 consecutive if-then statements. Last I hear he had the graveyard shift at an IHOP in Armonk, NY.

    --
    Don't Panic...
  142. I hate to say it... by Midnight+Ryder · · Score: 1

    I hate to say it, but, looking at some of the stuff I've coded, I think I've already got some stuff that could be entered into the contest that is currently in use!

    --

    Davis Ray Sickmon, Jr - looking for something to read? Check out my three free novels at MidnightRyder.org

  143. Re:Shortest Self Duplicating C program by storem · · Score: 1

    #include
    main(){char*c="\\\"#include<stdio.h>%cmain(){cha r*c=%c%c%c%.102s%cn%c;printf(c+2,c[102],c[ 1],*c,*c,c,*c,c[1]);exit(0);}\n";printf(c+2,c[102] ,c[1],*c,*c,c,*c,c[1]);exit(0);}

    -----------------------------
    no comment

  144. Re:first by Anonymous._.Coward · · Score: 1

    ... and the missing semi-colon;

    --

    take a triptonica to subthunk

  145. Re:www.ioccc.org by sparkes · · Score: 1

    I'm sorry but this still seems like the old timers club that it looked like when I started coding (now I am an old timer)

    What we need to remember is this is fun! don't forget all C (C++, Perl whatever) needs to be readable and maintainable in the real world.

    I know that this next line we incite a few people but LET THE COMPILER OPTIMISE FOR YOU.

    just had to get a few things off my chest

    Sparkes (carry on enjoying yourself people)

    *** www.linuxuk.co.uk relaunches 1 Mar 2000 ***

  146. Re:That was easy :) by Otis_INF · · Score: 1

    the basic crap was part of the fun ;) ah well ;)

    --
    Never underestimate the relief of true separation of Religion and State.
  147. From the official rules by luckykaa · · Score: 1

    Your entry must be [less than] 3217 bytes in length. The number of characters excluding whitespace (tab, space, newline), and excluding any ; { or } immediately followed by whitespace or end of file, must be [less than] 1536.

    Why would anyone want to add newlines, tabs or whitespace?

    1. Re:From the official rules by QZS4 · · Score: 2

      Why would anyone want to add newlines, tabs or whitespace?

      Have you seen the previous entries? A great example is the pi program from 1988 (westley.c). Without whitespace the whole charm of the program would be lost.

      Creative indentions can often make a program much sweeter in its source code appearance.

    2. Re:From the official rules by gorilla · · Score: 2
      Why would anyone want to add newlines, tabs or whitespace?

      Apart from some programs requiring white space in order to work (especially in printed strings), Sometimes it makes it prettier (This or This, you might need to view the source, as some browsers may reformat this on their rendered views).

  148. Hasn't the NSA tried to stop this yet? by CyberDong · · Score: 1
    Having been enjoying this type of contest for years, I'm surprised that the NSA doesn't step in and shut it down. Picture Mitnick giving the NSA the decryption algorithm for his data in the form of super-obfuscated braile-reading C code.

    Of course, I'm personally of the opinion that if you were supposed to be able to read it, they wouldn't call it "code."

    - - - -
    A forehead VCR... who'd buy that????

  149. Re:Moderation by Remote · · Score: 1

    Frankly, the karma itself is not the problem, I discarded a lot of it when I decided to change my username. What I think is that with moderation points comes responsibility. CmdrTaco is right when he says it is not wise to give power to someone to interfere in a system he/she does not understand. You can tell by my tone that I was not pissed off with Mr. Moderator, neither am I pissed off with you, I take your comment as a joke. But I really hope that Mr. Moderator takes a bit more care next time.

    Now, what is that STFU thing?

  150. Re:first by Remote · · Score: 1

    if (post.first()) { printf "FIRST POST!" }

    I don't think this will compile in C++ either.

  151. Obfuscated C code ? by Anonymous Coward · · Score: 2

    Just send in some of the code from the Linux kernel... Oh wait, they didn't say "Wall of C Code"...

  152. first by Anonymous Coward · · Score: 2

    if (post.first()) { printf "FIRST POST!" }

  153. Not really possible by adamsc · · Score: 2

    COBOL is just too verbose a language to obfuscate in the way you can obfuscate C. This does have its virtues, though - most of the programmers that I know who use both languages would prefer to debug 20 year old COBOL than 8 year old C.

    1. Re:Not really possible by adamsc · · Score: 2
      most of the programmers that I know who use both languages would prefer to debug 20 year old COBOL than 8 year old C.
      But I bet all of them (the sane ones anyway) would rather write something new with C. COBOL is a hideous language, on a par with Visual Basic ;)
      Only if you haven't updated your compiler in the last decade or so. Recent COBOLs are roughly even feature-wise with ANSI C as far as language constructs go and do have the advantage of being much easier to do things like indexed file I/O, screen input/output and accurate math (accountants get real picky about that).

      Given my druthers, I would use a modern language instead of either one. C is just too close to a macro assembler, neither is really good for graphics or networking and they're both showing their age by now. By now, programming in either one basically serves to remind me of why I prefer Java, PHP and Perl.

  154. Re:For All You Young Bucks by Chris+Hiner · · Score: 2

    Isn't "Obfuscated FORTRAN" redundant?

    *muttering something about silly F77 column positions that descended from punch cards*

  155. Re:One of my favorites... by Ed+Avis · · Score: 2
    I've played a little tetris program somebody made that was practically immune to analysis other than to the compiler :-)

    Maybe that's a way to de-obfuscate programs. Just tell the compiler to assemble them, and the resulting assembler might be easier to understand than the source code. It would probably help to compile for a fairly simple RISC chip (eg ARM, MIPS) that has an easy-to-understand instruction set.

    Better still, create a new target processor for gcc that is a simple stack machine or something. Then you could compile your code to this. I think the JVM fits this description, so you could use something which compiles C to Java bytecode, and then use a Java decompiler to spit out Java source. I have no idea if this would be more readable, but it could hardly be any worse...

    --
    -- Ed Avis ed@membled.com
  156. Re:A True Obfuscated function. by doomy · · Score: 2

    Sorry, one begin was missing :) Here is the patch.

    10a11
    >begin
    --

    --
    ...free your source and the rest would follow...
  157. Fixes by doomy · · Score: 2

    #define begin {
    #define end }
    #define say if
    #define yell printf
    #define otherwise else
    #define play_q3 exit
    #define katz 1
    #define @ ;
    /* slash_posted returns a 1 if a new slashdot
    article has been posted */

    ac_poster_screams()
    begin
    say(slash_posted)
    begin
    yell("FIRST POST!")@
    play_q3@
    end
    otherwise
    begin
    yell("Bill Gates Naked and Petrified!")@
    slash_posted = katz;
    ac_poster_screams()@
    end
    end

    That's the final version.. now the patch..

    3c3
    #define say if
    5c5,7
    #define otherwise else
    > #define play_q3 exit
    > #define katz 1
    14a17
    > play_q3@
    18a22,23
    > slash_posted = katz;
    > ac_poster_screams()@
    --

    --
    ...free your source and the rest would follow...
  158. Where's my FORTH papers... by ch-chuck · · Score: 2

    18 yrs old, uncommented, looks like heiroglyphics to me now :) Hmmm, something about a 'stack'.

    Agent 32

    --
    try { do() || do_not(); } catch (JediException err) { yoda(err); }
  159. Re:css-auth anyone by Illume · · Score: 2

    It doesn't compile on my system (gcc version 2.95.2, glibc2) but you might want to check Illiads entry for this contest.

  160. Whatever the rules are gated wins by arivanov · · Score: 2

    Download gated code from ftp.merit.net. And try to read it. It was not written by me so I cannot submit it but I would indeed suggest the gated-people to submit it in the contest. Especially the BGP part.

    The problem here is that we have to cope with it for at least a few more months until zebra matures completely...

    --
    Baker's Law: Misery no longer loves company. Nowadays it insists on it
    http://www.sigsegv.cx/
  161. Re:Shortest Self Duplicating C program by seebs · · Score: 2

    Actually, that one isn't a "correct" quine, because printf takes variable arguments, and thus requires a prototype to be strictly correct.

    It's hard to do a short quine which is also strictly-conforming.

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  162. Re:Shortest Self Duplicating C program by seebs · · Score: 2

    1. It can't be strictly conforming code, it assumes ASCII.
    2. It's 5 lines, which is pretty long for "short" code. ;-)
    3. Even if you think you can assume ASCII, you *CANNOT* have literal newlines in strings.

    Try "-ansi -pedantic -Wall". It won't warn about the ASCII thing, but it'll catch the string with newlines.

    I generally find you need something equivalent to
    char b='\\',q='"',s='\'',n='\n';
    to be able to reproduce all the stuff you end up needing. ;)

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  163. Re:www.ioccc.org by seebs · · Score: 2

    Actually, no. If it's time critical, it should *NOT* be in assembly, in all probability, because the chances are that the compiler will outsmart you or the chip will change.

    Assembly is like saying "Moore's Law doesn't apply to me".

    Take your pick: Hand-optimized Pentium assembly, or EGCS code tuned for the Pentium II. :)

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  164. Re:Shortest Self Duplicating C program by seebs · · Score: 2

    Very clever, I like it.

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  165. Re:www.ioccc.org by seebs · · Score: 2

    Get current. Modern games are mostly C++. Ick. But it's not assembly, because it doesn't matter.

    Look at kernel code. Lots of it. Across a number of OS's and platforms.

    Assembly is *rare*, and for good reasons.

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  166. Re:Shortest Self Duplicating C program by Industrial+Disease · · Score: 2

    I saw one once that, IIRC, consisted of a string declaration and a printf statement which used said string as the formatting string and the argument to be substituted for the %s. Maybe 30-40 characters.

    --
    Weblogging Considered Harmful:
  167. google by QuMa · · Score: 2

    Slashdotted already... Get yours while they're hot at google

  168. Re:first language... by Jonathan_S · · Score: 2

    Speaking of DOS batch files, anyone play the old Microprose game XCom. A friend of mine pointed out that the whole game was tied together by the loop in ufo.bat. The world view would run until a ground mission, the exe would shut down leaving a temp file. The next thing in the batch loop would be the ground combat exe which would pick up the temp file, when ground combat was over it dropped a temp file and exited the batch loop started the world map which pickedup the temp file and contiuned.
    Very scary.

  169. Re:For All You Young Bucks by GregWebb · · Score: 2

    I can never remember which was which of APL and PL/1 but whichever I'm thinking of would be absolutely perfect for this. Obscure symbols, an obsession with making the code as small as possible and a general belief that it's easier to reimplement than try and understand someone else's code.

    You can see why not many people use it any more...

    Greg

    --

    Greg

    (Inside a nuclear plant)
    Aaaarrrggh! Run! The canary has mutated!

  170. Kinds of obfuscation by David+A.+Madore · · Score: 2

    There are several kinds of obfuscation. The ones you generally see in IOCCC's, e.g. using one-letter variable names, formatting in bizarre ways, making abstruse use of CPP, and so on, are IMHO far less interesting than true algorithmic obfuscation.

    Some obfuscation is easy to produce algorithmically. For example, it is easy to have a program that will parse a C listing, replace variable names by things like O0O0Ooo, make white space come out in strange ways, and so on. Or, compile the program using gcc -O6, take the assembler output, and decompile it in an obvious way.

    Much more interesting, I find, is the more ``algorithmic'' kind of obfuscation, where identifiers are not deliberately unclear, but where the overall pattern of execution is difficult to follow. Take the following Scheme example, and try to understand how it works: then you will see what I mean:

    (((lambda (foo) (newline) foo)
    (call-with-current-continuation (lambda (bar) bar)))
    ((lambda (foo) (write-char #\*) foo)
    (call-with-current-continuation (lambda (bar) bar))))

    There are programming languages where nearly every program is obfuscated (in both ways I descibed!), and it is very difficult to write one which is not. One such language I invented is Unlambda.

  171. first language... by cdlu · · Score: 2

    DOS Batch files!! they kicked!

    I wrote the word game of boggle in batch (6500 lines), and a batch script that randomly replied to questions. Random number generation in Batch was about 200 lines. :)

    Just a couple of weeks ago I wrote a calendar for a PS/2 in batch as we have a macintosh functioning as a clock, and a formerly abandonned ps/2 on the windowsill in our club office :) ... the calendar: 2800 lines... I've written three patches for it since, and its now over 5000 lines long.

    I even wrote a TSR manager in batch which allowed me, to the best of the programme's abilities, to load and unload TSRs, complete with a menu. :)

    All you need? getkey.com: B4 00 CD 16 B4 4C CD 21
    (ok ok so i have too much free time...had.....have)
    #include <signal.h> \ #include <stdlib.h> \ int main(void){signal(ABRT,SIGIGN);while(1){abort(-1); }return(0);}

  172. Found this on my HD by Inoshiro · · Score: 2
    #include
    main(t,_,a)char *a;{return!0 main(-86,0,a+1)+a)):1,t main(2,_+1,"%s %d %d\n"):9:16:t "@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q #n+,/#{l+,/n{n+,/+#n+,/#\
    ;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
    q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w '){){nl]'/+#n';d}rw' i;# \
    ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
    iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
    ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w ! nr'/ ') }+}{rl#'{n' ')# \
    }'+}##(!!/")
    :t :0 "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

    Nice and christmasy. Disclaimer: I used a perl script to escape it. Here's the perl script escaped to itself :-) #!/usr/bin/perl -p
    #
    # code2html - convert code to html for posting to slashdot
    #
    # tchrist@perl.com
    # Sunday, December 19th, 1999
    BEGIN { print "\n" }# and the spirit of awk...
    # first kill all the tabs
    1 while s{ \t + }
    { " " x (length($&)*8 - length($`)%8) }ex;
    # then the four standard naughty bits
    s/&/&/g;# must remember to do this one first!
    s/ s/>/>/g;# don't close too early
    s/"/"/g;# only in embedded tags, i guess
    # make lines break where they should
    s/^\s*$/

    / || s/$/
    /;
    # make sure spaces aren't squishticated so we
    # can do indentation and properly align comments
    s/( {2,})/'' x length($1)/ge;
    END { print "
    \n" }# ...shall be with us always

    ---

    --
    --
    Internet Explorer (n): Another bug -- that is, a feature that can't be turned off -- in Windows.
    1. Re:Found this on my HD by Inoshiro · · Score: 4
      Slashdot ate part of the code, both the perl and the C.. It's the preview but they haven't fixed. Damnit.. (I also hit submit instead of preview by accident -- Rob, could we have those on separate sides of the format specifier?)... Have fun

      #include <stdio.h>
      main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
      main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94 ,-27+t,a)&&t==2?_<13?
      main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
      "@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q #n+,/#{l+,/n{n+,/+#n+,/#\
      ;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
      q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w '){){nl]'/+#n';d}rw' i;# \
      ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
      iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
      ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w ! nr'/ ') }+}{rl#'{n' ')# \
      }'+}##(!!/")
      :t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main(( *a=='/')+t,_,a+1)
      :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
      "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}




      #!/usr/bin/perl -p
      #
      # code2html - convert code to html for posting to slashdot
      #
      # tchrist@perl.com
      # Sunday, December 19th, 1999
      BEGIN { print "<TT>\n" }# and the spirit of awk...
      # first kill all the tabs
      1 while s{ \t + }
      { " " x (length($&)*8 - length($`)%8) }ex;
      # then the four standard naughty bits
      s/&/&amp;/g;# must remember to do this one first!
      s/</&lt;/g;# this is the most important one
      s/>/&gt;/g;# don't close too early
      s/"/&quot;/g;# only in embedded tags, i guess
      # make lines break where they should
      s/^\s*$/<P>/ || s/$/<BR>/;
      # make sure spaces aren't squishticated so we
      # can do indentation and properly align comments
      s/( {2,})/'&nbsp;' x length($1)/ge;
      END { print "</TT>\n" }# ...shall be with us always

      ---

      --
      --
      Internet Explorer (n): Another bug -- that is, a feature that can't be turned off -- in Windows.
  173. Re:Let the IOCCC grade your students! by technos · · Score: 2

    You should told him that
    [BS MODE ON]
    'The [platform] C compiler limits the number of possible outstanding user-iterated conditionals to 32, unless you use a double-stage switch conditional, in which case you can stretch the number of allowed outstanding conditionals to 64. Remember, you're using a monolithic 32 bit compiler generating octal, okay? I think you can get around it by custom compiling GCC for [platform], but you have to hand-edit the sub-parser source. Just do a egrep in the appropriate source directory and change all of the 32s to 64s, and then go through again to change all of the 64s to 128'

    I used that on a family member that thought one huge 200 line case statement was the way to handle a command line interface efficiently. After I actually caught him peeking at GCC, I just wrote him a 20 line interpreter using a tree.

    --
    .sig: Now legally binding!
  174. Let the IOCCC grade your students! by technos · · Score: 2

    Having been a first-year programming student once, I know the crap that can get turned out. I think every CS instructor should submit at least one example of their students work, if only to show the professional obfuscators how well it can be done through plain amateurish ignorance. I seem to remember one classmate that wrote 800 lines of code, sans comments, to perform the simple action of reversing the order of a char array and inverting capitalization.. She didn't survive the class, and ended up in a Marketing degree..

    --
    .sig: Now legally binding!
  175. Re:For All You Young Bucks by Cheerio+Boy · · Score: 2


    Maybe old COBOL programmers too!

    The - Completely Obfuscated COBOL Code Contest

    Hmm... or maybe thats too obfusctated. ;-)




    The Tick - "Spoon!"

    --

    "Bah!" - Dogbert
  176. IOCCC is just a front for a secret plot! by syscrusher · · Score: 2

    They are trying to trick Micros~1 into open sourcing Windows 2000. This would be the first award that they could truly win on merit.

  177. why this is a good thing by jon_c · · Score: 2

    One of my most fund memories when I was learning program was flipping through a book full of obfuscated c contest winners (I forget the name of the book). The interesting thing about the book is about half contest entrees, and the rest we're tips on how to write good C.

    Many people will argue that this contest is a bad thing(tm), but I think without seeing totally unreadable code it's harder to appreciate truly beautiful code.

    My all time favorite was a program that solved the 8 queens problem in the while condition of a for loop.

    It looked *something* like this..

    for(i=zx= ,x=x=^; x*u*y*t!!==x%dh^h=7;x!t
    f+d^q*df*&g==m&c-=44(x=5%b;
    g=&g=*b!b%t^l=h&g!g^==0;x++)

    ;

    I love the semicolon on it's own line

    --
    this is my sig.
  178. Shortest Self Duplicating C program by jkleid · · Score: 2

    This is kinda off-topic, but I remember hearing about a contest to write the shortest self-duplicating C program (i.e. something that would spit out an exact copy of its own code). Someone submitted an empty file once, which is kind clever. But does anyone know of the next shortest?

    1. Re:Shortest Self Duplicating C program by rebrane · · Score: 3
      You mean quines. The above page is a pretty exhaustive resource. Since it's relatively brief, here's (AFAIK) the shortest C quine:

      char*f="char*f=%c%s%c;main()
      {printf(f,34,f,34,10);}%c";
      main(){printf(f,34,f,34,10);}

      Check out the Intercal quine. It's the most painful piece of source I've ever seen (and I keep up with the ioccc).

      --neil

  179. Moderation by Remote · · Score: 2

    Dear Mr. Moderator
    Please notice that that was msg #23, posted at 16:19 UTC and the only one comment under that thread that said something similar was posted at 16:18 UTC, so we couldn't see each other.
    Take a bit more care next time.

  180. New contest by QZS4 · · Score: 3

    Oh yeah, so where's the obfuscated Intercal code contest?

    Oh, maybe we should drop that...

  181. A True Obfuscated function. by doomy · · Score: 3

    #define begin {
    #define end }
    #define if say
    #define yell printf
    #define else otherwise
    #define @ ;
    /* slash_posted returns a 1 if a new slashdot
    article has been posted */

    ac_poster_screams()
    say(slash_posted)
    begin
    yell("FIRST POST!")@
    end
    otherwise
    begin
    yell("Bill Gates Naked and Petrified!")@
    end
    end

    --

    --
    ...free your source and the rest would follow...
  182. Obfuscated PERL contest? by jabber · · Score: 3

    No need! It already comes that way!!

    I can code that in three APL glyphs!

    --

    -- What you do today will cost you a day of your life.
  183. past winners by jetpack · · Score: 3

    Since www.ioccc.org seems to be unreachable at the moment (at least for me), you can amuse yourself by looking at previous winning entries

    Have fun :)

  184. Single entries to multiple contests? by dsplat · · Score: 3
    It would be interesting to see a single valid entry that could be submitted to more than one Obfuscated Foo Code Contest. Here are some of the contest announcements (not all current):


    --
    The net will not be what we demand, but what we make it. Build it well.
  185. Re:One of my favorites... by Tim+Behrendsen · · Score: 3

    By the way, I just tried it under gcc (I haven't tried it in a long time), and unfortunately it doesn't appear to work anymore. :(

    Anyone want to take a crack at debugging it? :)

    For you young 'uns, tiny basic took line numbers. The following should work:

    10 for i = 0 to 10
    20 print i
    30 next i
    run

    I think it also has a full expression evaluator built in, so you can do some "let j = i * 10" type thing also.


    --

  186. That was easy :) by Otis_INF · · Score: 3

    10 print "In reality I'm an obfuscated version of msvcrt.dll"
    20 goto 10

    --
    Never underestimate the relief of true separation of Religion and State.
  187. For All You Young Bucks by ShelbyCobra · · Score: 3

    Perhaps the same website should have an "old timer's league" as well.

    I can see it now "The Grande Olde Obfuscated FORTRAN Code Contest"

    --

    -ShelbyCobra

    Living life in the right side of the s-plane

  188. css-auth anyone by Anonymous Coward · · Score: 4

    I don't have the time, but an obviscated css-auth formated in the shape of the DVD logo would be neat. You could print it on t-shirts and the like without people realizing what they are looking at.

  189. Unfortunately... by jd · · Score: 4

    The Martian entry, due to be received by the Mars Lander and beamed back to Earth in time for this year's contest, was disqualified on account of being too obscure, causing the main on-board computer to explode.

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  190. Re:One of my favorites... by MbM · · Score: 4
    correction to above example,
    5th line after the #defines is

    (!Q(s,"\"")){U("",'#');U("=",'!');}d=B;while(*F=*s ){*s=='"'&&j


    after that it should compile with a few warnings
    reminder to use uppercase, most of the computers that ran this stuff didn't have working shift keys
    - MbM
    --
    - MbM
  191. www.ioccc.org by seebs · · Score: 4

    And yes, we're late. Sorry! It takes some coordination getting things set up.

    We've already got a number of entries. Remember, you can enter as often as you like.

    Many will enter! Some will win! Some will elicit reactions of abject terror!

    --
    My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  192. Re:Writing Unintelligeable code by Azog · · Score: 4

    Here's the core of an email I just sent as an update to the unmaintainable code document.

    But my experience is so awful I must share the agony with as many as possible. So here you are - another way to write unmaintainable code...

    (cue creepy music)
    --------------------------------------

    When implementing a very complicated algorithm, use the classic software engineering principles of doing a sound design before beginning coding. Write an extremely detailed design document that describes each step in a very complicated algorithm. The more detailed this document is, the better.

    In fact, the design doc should break the algorithm down into a hierarchy of structured steps, described in a hierarchy of auto-numbered individual paragraphs in the document. Use headings at least 5 deep. Make sure that that when you are done, you have broken the structure down so completely that there are over 500 such auto-numbered paragraphs. For example, one paragraph might be: (this is a real example)

    1.2.4.6.3.13 - Display all impacts for activity where selected mitigations can apply
    (short pseudocode omitted).

    THEN... (and this is the kicker) when you write the code, for each of these paragraphs you write a corresponding global function named:

    Act1_2_4_6_3_13()

    Do not document these functions. After all, that's what the design document is for! HAHAHAHAHAHA!

    Since the design doc is auto-numbered, it will be extremely difficult to keep it up to date with changes in the code (because the function names, of course, are static, not auto-numbered.) This isn't a problem for you because you will not try to keep the document up to date. In fact, do everything you can to destroy all traces of the document.

    Those who come after you should only be able to find one or two contradictory, early drafts of the design document hidden on some dusty shelving in the back room near the dead 286 computers.

    ---------------------------

    Here's a real-life typical code snippet produced using this diabolical method:

    if (pProject->GetSecImpactStore()->ConnectedToPrimary (pSuccImpact))
    {
    wPrevFD= pSuccImpact->GetFD();
    wPrevECD= pSuccImpact->GetECD();
    wPrevEUCD= pSuccImpact->GetEUCD();

    // Act 1.2.4.6.4.11.7 recompute firing degrees, given different predecessors
    // (this is identical to Act 1.2.4.6.3.13)
    Act1_2_4_6_3_13(pSuccImpact, pProject->GetSecImpactStore());

    // Then propagate I2, given that its firing degrees may have changed
    Act1_2_4_6_4(pSuccImpact, wPrevFD, wPrevECD, wPrevEUCD, pInfEng, pProject, pSecRules);
    }
    else
    {
    // No other predecessors, so depropagate I2 also (recursion)
    if (!pStack->IsMember(pSuccImpact))
    {
    Act1_2_4_6_4_11( pInfEng, pProject, pSuccImpact, pSecRules, pStack );

    // Act 1.2.4.6.4.11.10 Then kill impact I2
    Act1_2_4_6_4_11_10( pInfEng, pProject, pSuccImpact, pProject->GetSecImpactStore() );
    }
    }

    This goes on for thousands of lines.
    --------------------------------------

    Thank you for sharing my pain.

    Torrey Hoffman (Azog)

    --
    Torrey Hoffman (Azog)
    "HTML needs a rant tag" - Alan Cox
  193. forget obfuscated C by / · · Score: 4

    I'm more interested in the obfuscated-justice contest they're having over at the Superior Court of the State of California County of Santa Clara. I keep trying to compile their efforts, but all I get is "error: INJUSTICE". Maybe I'm using the wrong Constitution? Does anyone have a totalitarian-state constitution I can link against? Maybe the old CCCP constitution?

    --
    "If one is really a superior person, the fact is likely to leak out without too much assistance" -- John Andrew Holmes
  194. Writing Unintelligeable code by thebruce · · Score: 4

    Here's a site for some pointers:

    http://mindprod.com/unmain.html

    Quite intriguing if you ask me :)

  195. 1988 Best Abuse Of The Rules by SEWilco · · Score: 5
    My favorite "Best Abuse Of the Rules" winner has always been spinellis.c

    In full:

    #include "/dev/tty"
  196. One of my favorites... by Tim+Behrendsen · · Score: 5

    Behold! A tiny BASIC interpreter that fits on one 24x80 screen:

    #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;i<11*R;i++)m[i]&&
    #define I "%d %s\n",i,m[i]
    #define X ;break;case
    #define _ return
    #define R 999
    typedef char*A;int*C,E[R],L[R],M[R],P[R],l,i,j;char B[R],F[2];A m[12*R],malloc
    (),p,q,x,y,z,s,d,f,fopen();A Q(s,o)A s,o;{for(x=s;*x;x++){for(y=x,z=o;*z&&*y==
    *z;y++)z++;if(z>o&&!*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<R;P[i++]=0);whi le(l){while(!(s=m[l]))l++;if
    (!Q(s,"\"")){U("<>",'#');U("<=",'$');U(">=",'!');} d=B;while(*F=*s){*s=='"'&amp ;&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,puts (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]<=M[*d]&&(l=L[*d]);}else p=B+2,P[
    *B]=S();l++;}X'L':N printf(I)X'N':N free(m[i]),m[i]=0 X'B':_ 0 t('S',5,"w",N
    fprintf(f,I))t('O',4,"r",while(fgets(B,R,f))(*Q(B, "\n")=0,G()))X 0:default:G()
    ;}_ 0;}G(){l=atoi(B);m[l]&&free(m[l]);(p=Q(B," "))?strcpy(m[l]=malloc(strlen(p
    )),p+1):(m[l]=0,0);}O(S,J,'=',==,'#',!=)O(J,K,'<', <,'>',>)O(K,V,'$',<=,'!', >=)
    O(V,W,'+',+,'-',-)O(W,Y,'*',*,'/',/)Y(){int o;_*p=='-'?p++,-Y():*p>='0'&&*p<=
    '9'?strtol(p,&p,0):*p=='('?p++,o=S(),p++,o:P[*p++] ;}

    I hope that translated right... Slashdot "Plain Old Text" option is a little broken, so I had to do some HTML translation. Oh well, it gives you the flavor of the IOCCC, anyway.


    --