Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

perl v/s C

by prad_intel (Monk)
on Nov 11, 2005 at 08:55 UTC ( [id://507668]=obfuscated: print w/replies, xml ) Need Help??

Hi All

Here is a C code which is said to have won the most obfuscated C code from IOCCC.

I am posting this here so that I know there are much capable and potential 'janta' ( people ) here who can do the same with perl and yet be more efficient than this one ( if possible )

#include <stdio.h> main(int t,char _,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;# ){n\ l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\ n'wk nw' iwk{K +K{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(a[ +31]):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);} output: 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 eighth 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.
Excuse me if i have gone wrong anywhere.

Regards

prad

Replies are listed 'Best First'.
Re: perl v/s C
by liverpole (Monsignor) on Nov 13, 2005 at 21:32 UTC
    The first time I saw the C version of this, I was amazed.  It was my first experience with obfuscated code in any language.

    Here's my attempt at a Perlish version:

    sub __{$_[0]=~y-=#&!~_`'.+,/<>():;?- .,eintsrahgldmfopv-;print@_} sub _{($,,$:)=split/=/,$_[0],2;$* =$*?"$:$*":$:;__ "O_=`,!=$,=>+y=:)=C,r~'`(+'=(y=`.u!=<:?!=/+?!=`:=(!$/$*#$/$/"}map{_$_ }")~.'`=+=;+.`.~>/!=~_=+=;!+.=`.!!","'!c:_>=`w:=`u.`<!=>:?!'=+_>=" ,"`,~.>=`,.!!=).!_c,=,!_'&=","):u.`,=):u.=c+<<~_/=b~.>'&$/" ,")~)`,=)~?!=/:<>!_=.~_/'&=","'~x`,='~x=/!!'!=+-<+y~_/&=" ,"'!?!_`,='!?!_='w+_'=+-'w~((~_/&$/","!~/,`,=!~/,`=(+~>'=+-(~<k~_/&=" ,"_~_`,=_~_!=<+>~!'=>+_c~_/&=","`!_`,=`!_=<:.>'=+-<!+;~_/&$/" ,"!<!?!_`,=!<!?!_=;~;!.'=;~;~_/&=","`w!<)`,=`w!<?!=>.u((!.'=>.u((~_/&= +"

      Wow, this is 90 chars shorter than what I get if I LZ77-compress it (see this old obfu of mine: LZ77 compression).

      sub j{'dr~Tt~~~wM~|t[~}r{~}ly~|dW~{sI~|n~}|aG~[tz~}iu~}d}}Sh1~{ w~}ry~ }n"~}h|~}hB||s~~~,|~|wQ}Gfm~}uD~|hr~Tf\\{{ "~}aX~}l<~|g|~}bw|{s9|{hH|3 iw~}tX{RiV~zoX~}d|~}r${{s~~~;.{ h&~{i~~~xY{RsIx| ?~|e$~| p~}-X~}ao~}i# {|,x~{vYy r3~mvB||tFxReRv{ t~}wB}|sqw{sR}}id~}m${{,{w aA}Wev~}gz~}tX{S eCtz d~|i|z| pw|mv~}l~~~kkwys"v e;|An<~|tX{Sn<~|eY~|aq~}iE}| q~|n"~}ij wzers g!{*tQvPt v{lm~}rjsyl6~|pouynMq lTy eNtslSvNeRly dn|py~}rb~|pxk| ijwztrn esw r9}^wSl|f@oQwSl|vJ}{r[~}mK~|rDq{roh{i=qyl~k nxu tN}Q'=~ /./g?ord$&:die$_}do{$_.=chr(j).substr($_,12096-&j-95*j,126-&j)until 0} if s""On the first day of Christmas my true love gave to me a partridge in a pear tree.\n\nOn the secon"
      Kudos liverpole,

      I knew one of the monk here could write the same with perl and am happy to see a result of my objective of posting it here. I have seen other obfuscations here and the best ever would be ...the Saturn rings ... which almost everyone has made it the best node ...

      happy to just be here ( and 'hear' the prayers of other monks ), more happiness to contribute and much more happiness if i am blessed with a long life in this monastery.

      Regards

      Prad

Re: perl v/s C
by TheHappySpaceInvader (Initiate) on Dec 14, 2005 at 13:16 UTC
    #!/usr/bin/perl @_ =('A' , 'a', 'Two', 'Three', 'Four' , 'FIVE', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'ing', 'in','geese', 'partridge' ,'swans', 'hens', 'birds', 'doves', 'danc', 'pear', 'call', 'tree', "\n", 'swimm', 'milk', 'leap' ,'pip', 'drumm', 'ers', 'turtle' , 'RINGS', 'french', 'maids', 'ladies', 'lords', 'GOLD', 'lay', 'and', ',', '.', '...'); @a=(&_____, &______.&_____,&_______.&______.&_____,&________. &_______.&______.&_____, &__________.&________.&_______. &______.&_____, &____________.&__________.&________.&_______. &______.&_____, &___________.&____________.&__________.&________. &_______.&______.&_____, &_________. &___________.&____________.&__________.&________. &_______.&______.&_____, &____.&_________.&___________. &____________.&__________.&________.&_______.&______.&_____, &___. &____.&_________.&___________.&____________.&__________.&________. &_______.&______.&_____, &__.&___. &____.&_________.&___________.&____________. &__________.&________.&_______.&______.&_____,&_.&__. &___.&____. &_________.&___________.&____________.&__________.&________.&_______. &______.&_____);sub _ {return "@_[12] @_[30]@_[31] @_[30]@_[13]@_[41] @_[25]"} sub ____________{return "@_[6] @_[15] @_[1]-@_[39]@_[13]@_[41] @_[25]" +} sub ___{return "@_[10] @_[37] @_[1]-@_[28]@_[13]@_[41] @_[25]"} sub __________ {return "@_[5] @_[38] @_[33]@_[43] @_[25]"} sub _____{return "@_[0] @_[16] @_[14] @_[1] @_[22] @_[24]@_[42] @_[25] +@_[25]"} sub ________{return "@_[4] @_[23]@_[13] @_[19]@_[41] @_[25]"} sub _______ {return "@_[3] @_[34] @_[18]@_[41] @_[25]"} sub ______{return "@_[2] @_[32] @_[20]@_[41] @_[40] @_[25]"} sub _________{return "@_[8] @_[35] @_[1]-@_[27]@_[13]@_[41] @_[25]"} sub ____{return "@_[9] @_[36] @_[21]@_[13]@_[41] @_[25]"} sub ___________ {return "@_[7] @_[17] @_[1]-@_[26]@_[13]@_[41] @_[25]"} sub __{return "@_[11] @_[29]@_[31] @_[29]@_[13]@_[41] @_[25]"} @_=('first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eightth', 'nineth', 'tenth' ,'eleventh', 'twelfth');$i=0; foreach (@a){print reverse(("\n",'...','me',' to ','gave',' love ', 'true','my ', ' Christmas ','of' ,' day ',@_[$i] ,'the ','On ')) ;sleep(3);print ;$i++;}
Re: perl v/s C
by sauoq (Abbot) on Nov 11, 2005 at 23:40 UTC

    Wow. I haven't seen that for almost 10 years. It is a really beautiful piece of C obfuscation. (Calling main() recursively was a nice touch.)

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: perl v/s C
by jarich (Curate) on Nov 25, 2005 at 10:20 UTC
    Very minor typo.
    i@bK '(q)
    at the start of the last line should be:
    i@bK'(q)

    That is, without the extra space character. Otherwise the output doesn't look so nice at all.

    Thanks for sharing this!

    jarich
Re: perl v/s C
by QM (Parson) on Nov 12, 2005 at 06:01 UTC
    You must have missed TheDamian's SelfGOL...

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://507668]
Approved by cristian
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found