IOCCC Accepting New, 'Improved' Entries 144
Rudolf writes: "The 16th International Obfuscated C Code Contest is open from now until 01 Dec 2001 23:59:59 UTC. Details are at the IOCCC web site. From the front page,
the contest goals are: -- To write the most Obscure/Obfuscated C program (within contest rules -- To show the importance of programming style, in an ironic way. -- To stress C compilers with unusual code. -- To illustrate some of the subtleties of the C language. -- To provide a safe forum for poor C code. :-)"
Compilers? (Score:1)
Some compilers become stressed easier than others.
Stress test C Compilers? (Score:2, Informative)
Over the years, gcc has survived the best. It has chucked core cookies on a few entries, but not nearly as often as some of the commercial C compilers.
If a winning entry does cause problems for somebody's C compiler, we usually file a bug report. They may not be pleased with the code sample, but that is the break;'s. :-)
p.s. The entry that broke causde the most problems on the most platforms was the 1988 Best of show [ioccc.org]. Not only did it crash a few C pre-processors, it cause one system to turn casters-up when it ran out of swap space!
Cute site (Score:2, Funny)
link [ioccc.org]
russians will win? (Score:2, Interesting)
Re:russians will win? (Score:3, Funny)
There are cases, often with complex logical expression with deeply nested parenthese, && and ||, where the assembly is easier to read than
the so called "high level" source code.
(Well, C is not high-level in any case)
Re:russians will win? (Score:2, Informative)
It's a well documented phenomena [tuxedo.org].
writing bad code (Score:1)
Once upon a time and once upon an office?
It must have been tried somewhere, maybe in Russia. And then they start sweating to get the bugs out.
The best way to make the code hard to decipher is to put a bad programmer on it. Although, in lisp...
Re:russians will win? (Score:2)
Re:russians will win? (Score:2)
Why Blame the Russians? (Score:1)
In the early days, IBM used to have "aptitude tests" that asked candidates whether they liked the "puzzles", e. g., in the newspapers and gave tests to evaluate this kind of "skill".
It took only a short step for programmers to realize that all programs could be written as "puzzles". If weak management accepted this, then you have Microsoft!
Now you know why all those old, old programs look the way they do!
Re:russians will win? (Score:2, Funny)
> Can anyone confirm this?
I have one story that is true.
When I worked on image recognition software (1999), the boss decided that we needed a new recognition engine. So he paid for some source code written by a Russian (the guy didn't speak English, with almost no net acess, and limited access to a phone.)
It was the worst piece of inefficient spagitti (crap) code I have ever seen. Variables names like j1, j2, j3, j4, j20, j22, and hardcoded array access like x[4] = , x[50] =, x[52] =. It took me a few months of reverse engineering and cleaning it up. I ended up just chucking it away, and starting from scratch, which was a valuable lesson for me -- If you're spending most of your time refactoring existing code, it's better to just chuck it away and start fresh with a clean design.
> Maybe the compiled code is even easier to understand...
It was! I also found it usefull to treat each function as a black box, and figure out
a) input (& are they const)
b) outputs (& are they const)
c) intermediate values
Ironically we had a co-worker Russion coder that was half decent. A little inexperienced on good coding practises, but a hard worker, and I could depend on him to get tasks done.
Obviously 2 people isn't a large statistical enough sample to draw any conclusions from.
Re: Good ole American obfuscation (Score:1)
Worried that we would lose our intellectual property, the company hired a consultant to determine the best way to obfuscate the code before sharing it. After looking over the code, the consultant noted that we didn't need to do a thing to it to prevent others from understanding it!
Ken (a 1997 winner of the IOCCC)
I have wanted to ask... (Score:2, Funny)
"Ken (a 1997 winner of the IOCCC)"
Do you point this accomplishment out to prospective employers? Do they view it as a positive thing? :)
Re:I have wanted to ask... (Score:1)
Re: Good ole American obfuscation (Score:1)
Very old idea: Job security (Score:2)
Heck, that's not unique to Russians. It's alive and well in the West, that's fer damnsure.
Go to the Jargon File (www.jargon.org), and look up "job security".
When will they start an obfuscated perl contest? (Score:3, Funny)
That WOULD be too easy (Score:3, Insightful)
There's this thing called a comment... (Score:1)
Cat got your tongue? (something important seems to be missing from your comment
Damn it Jim! (Score:3)
Re:Damn it Jim! (Score:2)
ADD 1 TO COBOL STORING THE RESULT IN COBOL
Re:When will they start an obfuscated perl contest (Score:3, Funny)
Also, if you go to Perl Monks [perlmonks.org], there are heaps of people submitting obfuscated Perl code for judgement
Re:When will they start an obfuscated perl contest (Score:2)
Re:When will they start an obfuscated perl contest (Score:2)
Re:When will they start an obfuscated perl contest (Score:2, Informative)
http://www.sysadminmag.com/tpj/obfuscated/
Re:When will they start an obfuscated perl contest (Score:1)
Go to perlmonks.org and search for 'obfuscated' or 'perl golf' and you'll see what I mean. The original Perl Golf game was to find a word in the dict file that had 10 non-repeating characters and the winner was a solution that was only 14 characters worth of code. Now that's cool.
Seg: readable perl (Score:2)
[TMB]
Re:When will they start an obfuscated perl contest (Score:2, Funny)
Perl takes me back, though.
Every time I look at someone else's perl, I expect a line to end with "NO CARRIER"...
-l
Re:When will they start an obfuscated perl contest (Score:2)
This is a bunch of text to get past the "lameness filter". I'm tempted to make some pithy witticism about the basic lameness of lameness filters, but this should be sufficient.
Re:When will they start an obfuscated perl contest (Score:1)
Yes, that'd be to easy. Just any perl code would do. We could have a contest of the most readable, self-documenting and clearest perl code, though. But, then again, that might be too hard.
my fovorite (Score:4, Funny)
String getLetter( int index ){
String [] x = { "A", "B", "C", "D" };
for ( int i = 0; i < 4; i++ ){
if ( i == 0 && index ==0 )
return "A";
else if ( i == 1 && index == 1 )
return "B";
else if ( i == 2 && index == 2 )
return "C";
else if ( i ==3 && index == 3 )
return "D";
if ( i >= 4 )
break;
}
return null;
}
Are they getting paid by the line?
Re:my fovorite (Score:1)
Re:my fovorite (Score:1)
int x[100];
for(int iApple = 0; iApple < 100; ++iApple){
iApple[x] = iApple;
}
for(int iGrape = 99; iGrape >= 0; --iGrape){
printf("%d\n", (int)(99 - iGrape[x]));
}
Re:my fovorite (Even Better) (Score:1)
for(X = 0; X < 100; ++X){
X[x] = X;
}
for(;X > 0; --X){
printf("%d\n", (int)(100 - X[x]));
}
Re:my fovorite (Score:1, Flamebait)
Re:my fovorite (Score:1)
Re:my fovorite (Score:2)
Re:my fovorite (Score:1, Offtopic)
Re:and the ever popular (Score:2)
Re:and the ever popular (Score:1)
bool func()
{
if (true)
return true;
else
return false;
}
(Well, the function once was useful and instead of completely erasing it, it was changed to this)
Re:and the ever popular (Score:1)
Re:and the ever popular (Score:2)
Re:and the ever popular (Score:1)
If you're using COM interfaces it gets worse than that. The VARIANT_BOOL data type is defined as a 16-bit word taking the values False (0) and True (-1). As long as you test these against false there's not usually a problem, but if you test equal to true rather than is true, or if you negate the variable then weird things can happen. VB's Not operator blindly does a bitwise rather than logical negation even on Booleans, so if you take a Boolean variable (badly) returned from a COM object written in C++ it's entirely possible for both the following statements to get executed:
If var Then DoThis
If Not var Then DoThat
Solution: always return COM booleans from C++ using the idiom (var ? VARIANT_TRUE : VARIANT_FALSE)
Re:my fovorite (Score:1)
Why? Because many of the in-house 'programmers' weren't actually programmers; they were power users of particular apps programmed by others and critical to the operation of the company. No one else in the company was qualified to make the distinction, or technical enough to see that all the 'code' these guys wrote they downloaded from the internet and tweaked for their company's specs, while removing all copyright information.
In other words, they didn't understand anything but the most basic of programming elements.
When I was hired by these corporations I was usually handed off to the IS department and they would tell me what they'd want. I'd write a nice, elegant piece of code, turn it in, and they'd tell me to rewrite it because it was 'unnecessarily complicated'. Translation: they couldn't read it because they weren't capable of doing any real programming themselves. So I would often end up 'dumbing it down' until the IS people could follow along as I explained (in copious documentation) how everything worked.
Sometimes it was incredibly embarrassing and I'd throw away the code rather than add it to my portfolio. The worst such moment came when I wrote a Perl app for one of North America's largest timber companies (which shall remain nameless) that I had to revise FIVE TIMES. The last iteration had no subroutines or function calls because *nobody in the IS department understood what a function or subroutine was*. So for the app I did everything with GOTO statements - because they understood GOTO.
Yep. GOTO. Each and every jump in the code. GOTO. Quite challenging, actually, not being able to use subroutines or function calls. But it was so ugly, so heinous, and so...juvenile...I never told anyone about that job. I didn't want anyone to know that I'd written that incredible dog.
Sometimes bad code is written by bad programmers. Sometimes bad code is written *for* bad programmers.
Max
Re:hare-brained (Score:2, Funny)
Re:Is It Open to the Pros? (Score:2)
Re:Is It Open to the Pros? (Score:1)
p.s. Speaking of twisted array references I like Korn's: 1987 Best One Liner [ioccc.org]:
Try to figure out what it does without compiling it first. Over the years I have not found very many people who could do it correctly the first time.
It compiles with out any special flags:
Hint: it does not work the same on a Microsoft based system. :-)
Re:Is It Open to the Pros? (Score:1)
Re:Is It Open to the Pros? (SPOILERS) (Score:2)
#define unix 1
(unix)["have"]+"fun"-0x60) == &("fun"[("have"[unix] - 0x60)]) == "un";
and the rest flows pretty easily. I was amazed by its simplicity once I figured it out (after reading the hints and lots of pondering w/ the C manual). And yes, it does use your favorite trick...
Re:Is It Open to the Pros? (Score:1)
host% uname -v
FreeBSD 4.4-RELEASE #0: Fri Sep 21 17:54:34 EEST 2001 root@host:/usr/src/sys/compile/HOST
host% echo 'main() { printf(&unix["\021%six\012\0"],(unix)["have"]+ "fun"-0x60);}' > 1.c
host% make 1
cc -O -pipe -march=pentiumpro 1.c -o 1
host%
unix
host%
Other languages than C (Score:2, Insightful)
I'd really like to see obfuscated/weird code in a language less "obfuscatable" than C (maybe Java or somethingorother?).
In that way, "obfuscation" can be more a matter of weird program flow and such, instead of confusing (but not very "interesting") a?b:c-statements (whatever they're called, I've forgotten it) and other C specialties.
Obfuscation is more of a challenge if you don't have as many weird operators and such do go with, and you have to fool people some other way.
Perhaps an Obfuscated Pseudo Code Contest?
Re:Other languages than C (Score:1, Informative)
Jon
Re:Other languages than C (Score:2, Informative)
I doubt that other languages offer the same possibilities for befuddlement as C, but there's only one way to find out...
Re:Other languages than C (Score:1)
Re:Other languages than C (Score:1)
Just throwing obfuscated code constructs at the program isn't enough to win these days. (I know, I've tried.) To have a realistic chance of winning, your code has to excel in several ares of obfuscation (style, algorithm, abuse of the rules) and show economy and elegance and do something non-trivial.
Check out the winner last year that fit an entire X-Windows flight simulator into 1.5K of C code... can't link to it right now, but it's called "banks.c".
I'm going to enter again this year. I've got a program that I've progressively improved over several iterations. I just thought of a few ways to shave some bytes here and there; maybe I'll have enough room to squeeze in a graphical output routine...
The 1998 flight simulator (Score:1)
FYI: This year we are allowing use of OpenMotif [freshmeat.net] which should improve things for folks writing new X-Windows progs.
Re:Other languages than C (Score:1)
APL: naturally obfuscated... :-) (Score:1)
I humbly cast my vote on APL [izap.com]... It is a symbolic, naturally cryptic [chilton.com] ( warning: big gif of the non-ASCII charset ) language, delightful to use ( once you really grokked it ) just because of the amazing power of its one-liners [cloud9.net]...:-)
Anecdote (Score:5, Funny)
The highlight of the annual Computer Bowl occurred when
Bill Gates [ucr.edu],
who was a judge, posed the following
question [slashdot.org]
to the contestants:
After a moment of silence, Jean-Louis Gassee (ex-honcho at Apple) hit his buzzer and answered:
Mr. Bill's expression was, in the words of one who was there, "classic."
Re:Anecdote (Score:1)
This Computer Bowl story is true, BTW. I saw it on TV shortly after it happened. I marked out.
Correct (Score:2)
Recompilation of obfuscated Apache? (Score:1)
Here's my entry (Score:1)
printf("hello world!");
}
If that's not obscure, what is?
Re:Here's my entry (Score:1)
Re:Here's my entry (Score:1)
You're forgetting that you're allowed to specify the compile time flags. So passing -Dvoid=int to cpp would fix that, and make it a legal entry.
Re:Here's my entry (Score:1)
Not ANSI code, but it is C...
Oops (Score:1)
My favourite obfuscation (Score:2, Funny)
The only thing in main() is large drawing of a filled circle. And then it says
"If you want better accuracy, make a bigger drawing"!
Re:My favourite obfuscation (Score:1)
Re:My favourite obfuscation (Score:2, Funny)
Because you're now busy doing your job by reading Slashdot?
You wanna see really obscurifacted? (Score:2, Interesting)
and look under the C link.
1990 winner (Score:5, Interesting)
#define O(b,f,u,s,c,a)b(){int o=f();switch(*p++){X u:_ o s b();X c:_ o a b();default:p--;_ o;}}
#define t(e,d,_,C)X e:f=fopen(B+d,_);C;fclose(f)
#define U(y,z)while(p=Q(s,y))*p++=z,*p=' '
#define N for(i=0;io&&!*z)_ x;}_ 0;}main(){m[11*R]="E";while(puts("Ok"),gets(B)
)switch(*B){X'R':C=E;l=1;for(i=0;i",'#');U("=",
++;if(j&1||!Q(" \t",F))*d++=*s;s++;}*d--=j=0;if(B[1]!='=')switch(
X'R':B[2]!='M'&&(l=*--C)X'I':B[1]=='N'?gets(p=B
=B+2,S()&&(p=q+4,l=S()-1))X'P':B[5]=='"'?*d=0,p
()))X'G':p=B+4,B[2]=='S'&&(*C++=l,p++),l=S()-1 X'F':*(q=Q(B,"TO"))=0;p=B+5;P[i
=B[3]]=S();p=q+2;M[i]=S();L[i]=l X'N':++P[*d]',>)O(K,V,'$',=)
O(V,W,'+',+,'-',-)O(W,Y,'*',*,'/',/)Y(){int o;_*p=='-'?p++,-Y():*p>='0'&&*p
Re:1990 winner (Score:2, Informative)
Re:1990 winner (Score:2, Insightful)
Best of IOCCC (Score:1)
However, the greatest and longest laugh at a IOCCC BOF occurred when I presented your 1998 Best abuse of the rules [ioccc.org]. For those you were not there, his entry consisted of a single, simple Un*x portable line of code:
That Truely twisted entry is listed in my top 10 all time best IOCCC progs.Re:1990 winner (Score:1)
a couple of my favs (Score:3, Interesting)
When compiled and run, it prints out the 12 days of Christmas.
12days.c [enteract.com]
And this one is has very interesting source, I think it calculates pi.
pi.c [enteract.com]
Re:a couple of my favs (Score:1)
No clue what it does, but it's arranged as a series of letters.
And you've gotta read the hint file [ioccc.org] for http://www.ioccc.org/1995/heathbar.c [ioccc.org].
I can't find the one I wanted to link to... It was a program to print a maze, in the shape of a maze, that spelled the word "MAZE". Quite beautiful.
Re:a couple of my favs (Score:1)
If you want a really obfuscated languange.. (Score:1)
How's that for obfuscation?
Abuse of the rules (Score:2)
A few years back somebody submitted the definitive self-replicating (i.e. prints its own source code) program. It consisted of a 0-byte C file. The author pointed out that even though it's not technically a legal C program, most C compilers (including the one the IOCCC uses) will in fact accept it and proceed to spit out a binary that does nothing.
The most evil entry though has to be the Spinellis entry from 1988, which consists of the line #include "/dev/tty". This actually caused a change in the rules so that programs can't require user intervention to compile anymore, short of running make.
Re:Abuse of the rules (Score:1, Informative)
compilers (including the one the IOCCC uses) will in fact accept it and proceed to spit out a binary that does
nothing.
Let's see:
# touch test.c
# gcc test.c
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
Doesn't work anymore.
Re:Abuse of the rules (Score:1)
$ touch test.c
$ gcc -c test.c
$ ls -l test.?
-rw-r--r-- 1
-rw-r--r-- 1
Null code will compile.. it just won't link on its own.
Re:Abuse of the rules (Score:2, Informative)
There are some good examples of quines (self-replicating programs) at http://www.nyx.net/~gthompso/quine.htm [nyx.net]
Also, I like Esoteric Topics in Computer Programming [catseye.mb.ca]
Don't bother, its slashdotted... (Score:1)
Anyone got a mirror site/link?
Brian
--
100% Linux Based Web Hosting [assortedinternet.com]
new to this contest (Score:5, Informative)
(We gotta keep up with the code bloat like everyone else
(why 521? Well 521 is prime and 2^521-1 is a Mersenne prime and I like primes
Unobfuscaters? (Score:2, Funny)
It would also come in handy when I have to look at the code the interns wrote.
Re:Irony (Score:2, Insightful)
Yes C was written in one respect to save on key strokes, but that was when computers didn't have monitors - you punched keys (not so easy to press), and got your output on a teletype printer. God knows you wouldn't want to by typing Cobol programs this way.
My guess is that programmers probably took more time designing their program before they started keying it in. C, with short commands, and abbreviated syntax only made it easier to get your darn program into the computer.
BZZT (Score:2, Informative)
Also, C was not popular until we already had video terminals - and then, C was the UNIX-head-only language until the 80's.
You're so incredibly misinformed about computer history.
Re:Irony (Score:2, Insightful)
Often C allows the programmer to express things in a short (terse) form that are intrinsically "obvious".. if it's not, then it's obfusticated; which is allowed too... but it's not the compilers job to decide what humans can and can't easily read.
Re:Irony (Score:1)
Re:Irony (Score:2)
C was supposed to be a better (portable, mostly) assembly, a lot of its contracsts can be translated directly to proccessor instructions.
The most obvious thing is, of course, ++ and += type of thing.
You must also remember that C as we know it today (C99) isn't at all what K&R C was.
C actually got a lot of things from Pascal (function signatures, and variable types, frex) that made it a language much more suitable to write applications than it used to be. There was a reason why C was used to low level stuff up until the 90s, and why Pascal (or Borland's version of it) was so popular for so long.
As a note, Ada programmers have contests for *clear* code.
In a language that was designed to be as clear as possible.
Re:Irony (Score:2)
For example, is it more or less readable to have a
begin
do something
end
vs. a
{
do something
}
?
Both are equally readable, one just takes fewer keystrokes.
When you compare C to Pascal, you see how in every case, C is much more terse, but still, for the most part, readable.
And there are things like..
x++ or x += 2
instead of:
x
Granted, there are annoying idioms that hurt the readability of the code. The (a?b:c) construction sometimes falls into this range. Using x = (++a) + (b--) sort of idioms also falls into this range. But most of those are abuses of the language and not regularly intentional coding strategies.
Re:Irony (Score:1)
instead of:
x
In pascal, you use ':=' and not '=' to assign values, and thus reserve '=' for equality comparition instead of that horrible '=='. This, unfortunately is one of the things about C that Java should NOT have borrowed. On the other hand '=+' and '=-' are ok. 'a++' and 'b--' are also, but not when used in assignments:
String copying from 'The C programming language' by K&R:
while (*s++ = *t++);
This neat little piece of code copies the string t to s. Scary..
Re:Irony (Score:2)
And, really, either way you look at it, it's as orthogonal as possible.
For == to be comparison means that it is similar to !=. Both are nice two character operators, and also parallel =, etc. are the exceptions in this case. This also means that, with = be assignment, +=, -=, etc. are orthogonal.
:= is more mathematically correct, because assignment has little to do with equality, so that makes things more explicit. Then = is what it means, and is orthogonal with . However, then you have to make # the not equal operator if you want the not equals to be similar in form, or you have to use either or !=. This also means that the += operators should be +:= to be unambiguous.
The good thing, I suppose, would be to make
Java makes the = vs. == error harder to do by the simple requirement that an if () take a boolean value instead of an int or bool.
The best solution would be to switch to a unicode character set for programming, so that you could make everything perfectly regular and orthogonal. But that just plain sucks because you would need more keys on the keyboard or weird character combinations and the source would be a bitch to deal with.
Re:Irony (Score:2)
"*s++ = *t++" directly maps to a SINGLE instruction on many CPU architectures. eg: 'move (a0)+, (a1)+'
Those operators made it easier to make the compilers use the capabilities of the CPU.
Today, optimizing compilers can and do figure this out all on their own.
Number of keystrokes was not the issue. Too bad it has infected so many languages since. In fact, on some CPU's today just having the ++ and -- operators throws a monkey wrench into the optimizer as it does not allow for fine grained parallelism.
--jeff