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

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Obfuscated C Code Contest Begins 227

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.
This discussion has been archived. No new comments can be posted.

Obfuscated C Code Contest begins

Comments Filter:
  • by Anonymous Coward
    Actually, this year the Obfuscated Perl contest is being sponsored by the Department of Redundancy Department...
  • by Anonymous Coward
    ...that's KNF!
  • by Anonymous Coward
    C Code C Code run C Code not run? C Code RUN! RUN Damnit RUN!
  • by Anonymous Coward
    #!/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";
    }
  • by Anonymous Coward

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

  • by Anonymous Coward
    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.
  • 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.
    -----------
  • 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.

    --

  • 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 [152.7.41.11].
  • 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...)
  • And far more importantly, they should return something other than void.

    --

  • 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.

    --

  • 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.

    --

  • 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

  • If M$ would publish the source of Windows, they would surely won... Some unintelligible code that compile and run (sort of)...
  • I knew I missed something. This is why I never write code before noon. :-)
  • 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. */
  • ... er, actually, bob() and FNPTR() should accept (void) as parameters, not (). Please excuse my gross faux paux. :-)
  • I like the way you think!
  • ... er, and void functions hardly ever return 1. Damn, I'm on a roll :-)
  • Would that be "Effective C++", by Scott Meyers? :-)
  • 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.
  • 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).
  • 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
  • Either Scott Meyers is describing C++ or he's incompetent. A function prototype with an empty parameter list is not an ANSI function declaration.
  • 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.
  • oops ya, i caught that after i posted it. oh well.
  • 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.
  • A job at Nvidia.
  • <I>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.</I>

    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?

    --

  • Cute, but in Pascal, strings are delimited by ', not ", IIRC.

    --

  • 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!

    --

  • 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).

    --

  • ... 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.

    --

  • 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...

    --

  • 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.

    --

  • 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.

    --

  • Pascal semicolon use <B>is</B> consistent! In Pascal, a semicolon is a statement separator, not a statement terminator. You consistently put semicolons <I>between</I> statements.

    --

  • <I>Stuff like polymorphism is a lot cleaner syntactically in C++ than in C.</I>

    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.

    --

  • Yeah, writing obfuscated Perl is too easy. Perl code is often indistinguishable from line noise.

    --

  • goto
    goto
    goto



    AAAAaahhhh!

  • 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

  • by Anonymous Coward
    Just send in some of the code from the Linux kernel... Oh wait, they didn't say "Wall of C Code"...
  • by Anonymous Coward
    if (post.first()) { printf "FIRST POST!" }
  • 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.
  • 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.

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

    Daniel
  • Isn't "Obfuscated FORTRAN" redundant?

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

  • 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
  • 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...

  • 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.

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

    10a11
    >begin
    --
  • by doomy ( 7461 )
    #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()@
    --
  • Check out the source code to GTK [gtk.org] (or simply do some GTK programming).

    logan

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

    Agent 32
  • It doesn't compile on my system (gcc version 2.95.2, glibc2) but you might want to check Illiads entry [userfriendly.org] for this contest.
  • 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...
  • 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.
  • 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. ;)
  • 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. :)
  • Also incorrect.

    MAIN RETURNS INT YOU SIMPERING FOOLS!

    :)

    (No, really, it does. "void main" is Just Plain Wrong.)
  • >being itself an ascii pig comprised of >pig-latin'ed code.

    "comprising" or "composed of".
  • Very clever, I like it.
  • 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.
  • 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.
  • by QuMa ( 19440 )
    Slashdotted already... Get yours while they're hot at google [google.com]
  • 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.
  • 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
  • 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 [eleves.ens.fr].

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

    My favorite still has to be this one [rutgers.edu] 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.
  • 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 [ioccc.org] or This [ioccc.org], you might need to view the source, as some browsers may reformat this on their rendered views).

  • Hey, if I wrote maintainable code, they'd be able to hire someone to replace me.
  • 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);}
  • #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

    ---

  • 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.
  • 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..


  • Maybe old COBOL programmers too!

    The - Completely Obfuscated COBOL Code Contest

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




    The Tick - "Spoon!"
  • 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.
  • 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 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?
  • 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.
  • by QZS4 ( 7063 ) on Wednesday February 02, 2000 @07:45AM (#1311350) Homepage

    Oh yeah, so where's the obfuscated Intercal [tuxedo.org] code contest?

    Oh, maybe we should drop that...

  • by doomy ( 7461 ) on Wednesday February 02, 2000 @08:53AM (#1311351) Homepage Journal
    #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

    --
  • by jabber ( 13196 ) on Wednesday February 02, 2000 @08:05AM (#1311352) Homepage
    No need! It already comes that way!!

    I can code that in three APL glyphs!
  • by rebrane ( 17961 ) on Wednesday February 02, 2000 @08:30AM (#1311353)
    You mean quines [nyx.net]. 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

  • by jetpack ( 22743 ) on Wednesday February 02, 2000 @07:42AM (#1311354) Homepage
    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 [uu.net]

    Have fun :)
  • by dsplat ( 73054 ) on Wednesday February 02, 2000 @07:53AM (#1311355)
    It would be interesting to see a single valid entry that could be submitted to more than one Obfuscated [tuxedo.org]Foo [tuxedo.org] Code Contest. Here are some of the contest announcements (not all current):


  • by Tim Behrendsen ( 89573 ) on Wednesday February 02, 2000 @08:20AM (#1311356)

    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.


    --

  • by Otis_INF ( 130595 ) on Wednesday February 02, 2000 @08:14AM (#1311357) Homepage
    10 print "In reality I'm an obfuscated version of msvcrt.dll"
    20 goto 10
  • by ShelbyCobra ( 134614 ) on Wednesday February 02, 2000 @07:22AM (#1311358)
    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"
  • by Anonymous Coward on Wednesday February 02, 2000 @07:33AM (#1311359)
    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.
  • by jd ( 1658 ) <[moc.oohay] [ta] [kapimi]> on Wednesday February 02, 2000 @07:08AM (#1311360) Homepage Journal
    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.
  • by MbM ( 7065 ) on Wednesday February 02, 2000 @01:46PM (#1311361) Homepage
    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
  • by seebs ( 15766 ) on Wednesday February 02, 2000 @07:09AM (#1311362) Homepage
    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!
  • by Azog ( 20907 ) on Wednesday February 02, 2000 @12:07PM (#1311363) Homepage
    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)
  • by / ( 33804 ) on Wednesday February 02, 2000 @07:11AM (#1311364)
    I'm more interested in the obfuscated-justice contest [min.net] 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?
  • by Inoshiro ( 71693 ) on Wednesday February 02, 2000 @01:25PM (#1311365) Homepage
    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

    ---

  • by thebruce ( 112025 ) on Wednesday February 02, 2000 @07:03AM (#1311366) Homepage
    Here's a site for some pointers:

    http://mindprod.com/unmain.html [mindprod.com]

    Quite intriguing if you ask me :)
  • by SEWilco ( 27983 ) on Wednesday February 02, 2000 @08:31AM (#1311367) Journal
    My favorite "Best Abuse Of the Rules" winner has always been spinellis.c [uu.net]

    In full:

    #include "/dev/tty"
  • by Tim Behrendsen ( 89573 ) on Wednesday February 02, 2000 @08:07AM (#1311368)

    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.


    --

The cost of feathers has risen, even down is up!

Working...