Skip to main content
gamedev.net
🔒 Locked

Obfuscated Code

Started by Programmer One Apr 10, 2002 at 9:51 PM 19 replies 450+ views
Original Post
Programmer One
Programmer One
I thought one of the goals in programming is making your code understandable... The following is an actual program....try to figure out what it does WITHOUT COMPILING IT...I tested it, and it does compile (with a few modifications) under MSVC++ 6
  
#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);
  
Ya know...they even made a contest out of it... _____________________________________________________ ICQ #: 149510932 Google - OpenGL - DirectX - Windows Guide Network - MSDN - Symantec Virus Info "Imagination is more important than knowledge." - Albert Einstein
Pouya
Pouya
Wow, Programmer One finally finds the 17-year-old IOCCC.

So All I can say is: Hello and welcome to 17 years ago!
Programmer One
Programmer One
quote:
Original post by pouya
Wow, Programmer One finally finds the 17-year-old IOCCC.

So All I can say is: Hello and welcome to 17 years ago!


Oh, ok, old timer...




_____________________________________________________

ICQ #: 149510932

Google - OpenGL - DirectX - Windows Guide Network - MSDN - Symantec Virus Info

"Imagination is more important than knowledge." - Albert Einstein

dwarfsoft
dwarfsoft
Does it print out the 12 days of christmas? Beacuse I ahve seen and compiled that one before, and it seems fairly similar

ACTUALLY... I change my mind... it IS the twelve days of christmas

main(t,_,a) gave it away to my memory


-Chris Bennett of Dwarfsoft - The future of RPGs GPA Thanks to all the goblins in the GDCorner niche
dwarfsoft
dwarfsoft
under borland I believe I had to compile it more like this:


    
#include <stdio.h>

main1(t,_,a) char *a; { ... } /* all that stuff in here, changing all recursive calls to "main" to "main1" instead */

main(t,_,a) char *a; { main1(t,_,a); }


because it wouldn't work otherwise

-Chris Bennett of Dwarfsoft - The future of RPGs GPA Thanks to all the goblins in the GDCorner niche

[edited by - dwarfsoft on April 10, 2002 11:38:37 PM]
Null and Void
Null and Void
quote:
Original post by dwarfsoft
changing all recursive calls to "main" to "main1" instead

C++ doesn''t allow recursion of main, but I''m pretty sure that C does. Maybe that''s why?

dwarfsoft
dwarfsoft
yeah, well I didn''t have a simple C compiler, and anyway, I am only recalling this from memory. I don''t have my borland cd and the only thing I have installed is MSVC6, which although may compile will not run as expected.

Oh, and for MSVC6 I believe you need to initialise t as an int.

-Chris Bennett of Dwarfsoft - The future of RPGs GPA Thanks to all the goblins in the GDCorner niche
LessBread
LessBread
What''s the shortest C program that will compile and crash when run?
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Pouya
Pouya
quote:
Original post by LessBread
What''s the shortest C program that will compile and crash when run?


Windows:

#include <windows.h>
void main() { HWND blah; UpdateWindow(blah); } /* uninitialized */


Unix: This is my favorite

void main() { while(1) fork(); }

LessBread
LessBread
quote:
Original post by Oluseyi
void main() { while(1) fork(); }

Your sysadmin will kill you for that!


Lol!

How long shall I wait before providing the answer?
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
LessBread
LessBread


Do not meddle in the affairs of moderators, for they are subtle and quick to anger.



[edited by - dwarfsoft on April 11, 2002 6:43:20 AM]
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Sandman
Sandman
quote:
Original post by pouya
Windows:

#include <windows.h>
void main() { HWND blah; UpdateWindow(blah); } /* uninitialized */


Unix: This is my favorite

void main() { while(1) fork(); }




I disagree:

void main() {int i=0;1/i;}

is shorter. But not as much fun as the unix one.

EDIT: Meh. Still wrong.


[edited by - Sandman on April 11, 2002 6:10:59 AM]
LessBread
LessBread
quote:
Original post by dwarfsoft
Do not meddle in the affairs of moderators, for they are subtle and quick to anger.



Um, well, interesting to find my posts censored - considering that the exchange with dwarfsoft was pretty mild as they go. Whatever.

At any rate, again here''s the answer to the question I asked above since dwarfsoft removed it along with the other comments:


  
main;
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Gabriel Fleseriu
Gabriel Fleseriu
please open a new .CPP file, write

main;

into it, and try to compile.

[edit]darn, it compiles under C. Mea Culpa.

Forever trusting who we are
And nothing else matters
- Metallica


[edited by - Gabriel Fleseriu on April 11, 2002 4:03:45 PM]
Forever trusting who we areAnd nothing else matters - Metallica
LessBread
LessBread
quote:
Original post by Gabriel Fleseriu
[edit]darn, it compiles under C. Mea Culpa.



Lol! I wouldn''t have asked if I wasn''t certain of the answer, but don''t think I though it up myself. The fellow who wrote the compiler I use told me about it.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Gabriel Fleseriu
Gabriel Fleseriu
I guess I use C++ for too long by now. A source file like

main;

triggers my automathical bullshit detector. As I said: mea culpa - you right, me wrong.

[edit]typo

Forever trusting who we are
And nothing else matters
- Metallica


[edited by - Gabriel Fleseriu on April 11, 2002 4:40:54 PM]
Forever trusting who we areAnd nothing else matters - Metallica

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.