Marc Posted June 17, 2004 Share Posted June 17, 2004 I was thinking about this the other day and decided to look it up... Anyone who has the gumption to try this, #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);} Compile and run that hunka code and you'll be pleasantly surprised. Ciao Marc P.S. And I don't mean pleasantly surprised by a disk crash or something... I mean pleasantly surprised in a 'wow, thats cool' kinda way P.P.S I just tried it and there were some warnings, but it still worked. Quote Link to comment Share on other sites More sharing options...
Marc Posted June 17, 2004 Author Share Posted June 17, 2004 oh, and by compile, I mean with gcc or vc++. Quote Link to comment Share on other sites More sharing options...
renderpipe Posted June 17, 2004 Share Posted June 17, 2004 hahaha that's cool! Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 17, 2004 Share Posted June 17, 2004 Hehe So; are you thinking about entering this year's IOCCC contest? Thanks Marc. That was fun Quote Link to comment Share on other sites More sharing options...
Guest Guest Posted June 17, 2004 Share Posted June 17, 2004 Ok guys, for those of us who don't compile, what the heck does it do Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 17, 2004 Share Posted June 17, 2004 Ok guys, for those of us who don't compile, what the heck does it do WARNING: SPOILER!!! It prints out the following: On the first day of Christmas my true love gave to me a partridge in a pear tree. On the second day of Christmas my true love gave to me two turtle doves and a partridge in a pear tree. On the third day of Christmas my true love gave to me three french hens, two turtle doves and a partridge in a pear tree. On the fourth day of Christmas my true love gave to me four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the fifth day of Christmas my true love gave to me five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the sixth day of Christmas my true love gave to me six geese a-laying, five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the seventh day of Christmas my true love gave to me seven swans a-swimming, six geese a-laying, five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the eigth day of Christmas my true love gave to me eight maids a-milking, seven swans a-swimming, six geese a-laying, five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the ninth day of Christmas my true love gave to me nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the tenth day of Christmas my true love gave to me ten lords a-leaping, nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the eleventh day of Christmas my true love gave to me eleven pipers piping, ten lords a-leaping, nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. On the twelfth day of Christmas my true love gave to me twelve drummers drumming, eleven pipers piping, ten lords a-leaping, nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five gold rings; four calling birds, three french hens, two turtle doves and a partridge in a pear tree. Cute, huh? Quote Link to comment Share on other sites More sharing options...
Guest xionmark Posted June 17, 2004 Share Posted June 17, 2004 Hey now that's cool!!! --Mark Quote Link to comment Share on other sites More sharing options...
Marc Posted June 17, 2004 Author Share Posted June 17, 2004 Hehe So; are you thinking about entering this year's IOCCC contest? Thanks Marc. That was fun Actually, this one was 1988's winner of the ioccc contest. I remember being fresh out of college and being awestruck by it. Now here I am 10 years later and I'm still in the same boat.. . Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 17, 2004 Share Posted June 17, 2004 Now here I am 10 years later and I'm still in the same boat.. . Yup. WAY KEWL stuff. I looked at it a little more, and even if I ignore all the string obfuscation (my gut tells me they are ascii offsets, with each offset passed in as the arguments that would normaly be argc and argv [?]), I *still* can't even get past the first statement! I mean... How the heck is this legal C code?! main(t,_,a)char *a; { } It would never make it through a C++ compiler, but just *how* is main(t,_,a)char * a type ?!? If you remove the pointer-to-char, then it's just the definition of main() (one that can get through a C-compiler at least). But then what role does the char * play? Is it some obscure syntax to force main() to have a return type that is not int? (i.e: a screwd up way to type-cast main() ??? ) And since when does main() take *3* arguments (one of them being "_") ?!? ... and yet the compiler swallows it all with barely a complaint... crazy stuff... Any clues ? Quote Link to comment Share on other sites More sharing options...
Jason Posted June 17, 2004 Share Posted June 17, 2004 I got curious and just wanted to find out how many unique words where in the poem, and look st at this: On the first day of Christmas my true love gave to me a partridge in pear tree. second two turtle doves and third three french hens fourth four calling birds fifth five gold rings; sixth six geese a-laying seventh seven swans a-swimming eigth eight maids a-milking ninth nine ladies dancing tenth ten lords a-leaping eleventh eleven pipers piping twelfth twelve drummers drumming Thats 62 unique words from the full 425. I guess herein lies the secret of COMPRESSION. Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 18, 2004 Share Posted June 18, 2004 Thats 62 unique words from the full 425.I guess herein lies the secret of COMPRESSION. You are right, of course, but a listing of the unique words is not the same as the poem. So you'd still need to encode the rules that use those words to make sentences, add punctuation, split them into 12 paragraphs, etc. etc. Having said that, the source code before compilation is 817 bytes long, whereas a gzipped version of the entire formatted output is only 317 bytes... so no; it doesn't get any medals for compression But it *is* a very impressive example of obfuscation; you gotta admit. This thing is pretty damn hermetic (to me at least). I was just wondering if there was an online copy of the ansi-c standard somewhere... that main() declaration is driving me nuts! Off I go to google land... Quote Link to comment Share on other sites More sharing options...
edward Posted June 18, 2004 Share Posted June 18, 2004 I mean... How the heck is this legal C code?! main(t,_,a)char *a; { } It's using K&R old-style C declarations. I probably still have a copy down in the basement somewhere. Everything probably defaults to int for the untyped stuff. So filling for this, the more recognizeable style would be: int main(t, _, a) int t; int _; char *a; { } New style would be: int main(int t, int _, char *a) { } Of course, we're still not ANSI C yet that's not the standard declarction for main(). Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 18, 2004 Share Posted June 18, 2004 It's using K&R old-style C declarations. OH-MY-GOD-YES-OF-COURSE!! ... DUH! I haven't seen that style used in so long I forgot all about it! Aaaahhhhhh.... much better now..... Thanks Edward! I can sleep tonight! Quote Link to comment Share on other sites More sharing options...
Marc Posted June 18, 2004 Author Share Posted June 18, 2004 While I was looking for it I found a link to this : reverse engineered It doesn't clarify much, but its still cool Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.