Jump to content
xisto Community
cse-icons

Crazy Looking C Program Interesting

Recommended Posts

hi friends,

Have a look at the following code... Can u guess what this wud do...
nope... no virus nor executable code... It is a completely valid and compilable C program...
dont worry.. I have executed it on my system and it perfectly nice program :lol:

#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;# ){n\l]!/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(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);}

ok... so u give up....
put it in ur compiler and execute it...

surprised......
yup there is a contest held every year, as to who can come up with craziest looking programs and the design and beauty of the program is taken into consideration to decide the winner....

I had a collection of such programs somewhere on my system.. will post them when I find them...

Cheers.

Share this post


Link to post
Share on other sites

hmmm.... creative!!!!sorry, i'm not game enuf to compile and run it :(, but yep there's points for randomness and creativity!!!next year it needs to be written in such away that it looks like something by Leonardo Da Vinci :lol:

Share this post


Link to post
Share on other sites

Hi friends,I dont know how you wud compile it in Visual studio. I do it in Turbo C compiler or turbo c++.It compiles without even a warning....Here is the output.... --------------------------------------------------------------------On the first day of Christmas my true love gave to mea partridge in a pear tree.On the second day of Christmas my true love gave to metwo turtle dovesand a partridge in a pear tree.On the third day of Christmas my true love gave to methree french hens, two turtle dovesand a partridge in a pear tree.On the fourth day of Christmas my true love gave to mefour calling birds, three french hens, two turtle dovesand a partridge in a pear tree.On the fifth day of Christmas my true love gave to mefive gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.On the sixth day of Christmas my true love gave to mesix geese a-laying, five gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.On the seventh day of Christmas my true love gave to meseven swans a-swimming,six geese a-laying, five gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.On the eighth day of Christmas my true love gave to meeight maids a-milking, seven swans a-swimming,six geese a-laying, five gold rings;four calling birds, three french hens, two turtle dovesand a partridge in a pear tree.On the ninth day of Christmas my true love gave to menine 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 dovesand a partridge in a pear tree.On the tenth day of Christmas my true love gave to meten 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 dovesand a partridge in a pear tree.On the eleventh day of Christmas my true love gave to meeleven 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 dovesand a partridge in a pear tree.On the twelfth day of Christmas my true love gave to metwelve 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 dovesand a partridge in a pear tree.--------------------------------------------------------------------unbelievable..............but true...in case u dont believe it, just try it out... even gcc or linux based c compilers should work...Cheers.

Share this post


Link to post
Share on other sites

The following is one of the winners of 2004 International Obfuscated Code contest

#include <ncurses.h>/*****************************************************/            int               m[256                   ] [         256   ],a ,b  ;;;  ;;;   WINDOW*w;   char*l=""   "\176qxl"   "q"   "q"   "k"   "w\xm"   "x"   "t"         "j"         "v"         "u"         "n"         ,Q[ ]=   "Z"   "pt!ftd`"   "qdc!`eu"   "dq!$c!nnwf"/**   ***   */"t\040\t";c(int   u ,         int         v){                     v?m   [u]         [v- 1]   |=2,m[u][v-1] &   48?W][v-1   ] &   15]]):0:0;u?m[u   -1][v]|=1   ,m[ u-               1][   v]&         48?               W-1   ][v         ]&15]   ]):0:0;v<   255   ?m[   u][v+1]|=8,m[u][v+1]&   48?   W][   v+1]&15]]):0         :0;         u <               255   ?m[   u+1         ][v   ]|=4,m[u+1][   v]&48?W+1][v]&15]]):0:0;W][   v]&   15]   ]);}cu(char*q){   return *q               ?cu   (q+         1)&         1?q   [0]               ++:q[0   ]--   :1;   }d(   int   u ,   int/**/v,   int/**/x,   int   y){   intY=y   -v,   X=x         -u;   int         S,s  ;Y<         0?Y   =-Y   ,s,s=-   1:(   s=1);X<0?X=-X,S   =-1  :(S=   1);   Y<<=   1;X<<=1;   if(X>Y){int   f=Y               -(X   >>1   );;               while(u!=         x){f>=   0?v+=s,f-=X:0;u   +=S  ;f+=   Y;m[u][v]|=32;mvwaddch(w,v   ,u,   m[u ][               v]&   64?   60:         46)        ;if         (m[   u][v]&16){c(u,v);;  ;;;  ;;;   return;}}   }else{int   f=X   -(Y>>1);;   while (v   !=y         ){f   >=0         ?u   +=S,               f-=         Y:0;v   +=s  ;f+=X;m[u][v]|=   32;mvwaddch(w,v   ,u,m[u][v]&64?60:46);if(m[u ][                     v]&         16)   {c(   u,v                     ); ;   return;;;}}}}Z(   int/**/a,   int   B){   }e(   int/**/y,int/**/  x){int               i;         for         (i=         a;i               <=a+S;i++)d(y,x,i,B),d(y,x,i,b+L);for(i=b;i<=b+L;i++)d(y,x,a,i),d(y,x,a+   S,i );                    ;;;        ;;;        ;;;              ;;;  ;  mvwaddch(w,x,y,64);  ;;;  ;;;  ;;;   prefresh(   w,b,a,0,0   ,L-   1,S-1);}             main(         int               V ,   char              *C[  ]   ){FILE*f=   fopen(V==1?"arachnid.c"/**/   :C[   1],"r");int/**/x,y,c,v=0        ;;;      initscr              ();               Z(Z         (raw ()   ,Z(   curs_set(0),Z(1   ,noecho()))),keypad(    stdscr,TRUE));w   =newpad  (   300,  300               );   for         (x=   255  ; x   >=0  ;x--  )   for   (y=   255  ;y>=0;y--   )m[   x][   y]=   0;x=y=0;refresh( );while  (   (c=                           fgetc (f)   )+1)                    {if(0||c==10||  x==   256){x=0;y++;if(y==256  )break;;}   else{m[x][y]=(c   =='~'   ?64   : c   ==32              ?0:         16)  ;;x               ++;      }}for(x=0  ;x<   256;x++)m   [x][0]=16   ,m[   x][   255]=16;for(y=0;y<         256  ; y         ++)   m[0         ][y   ] =               16,m[255][y]   =16  ;a=b=c=0;   x=y   =1;   do{v++;mvwaddch   (w,   y,x   ,m[x][         y]&               32?   m[x                     ][y   ] &   16? 0|   acs_map[l[m[x][y]&15]]:46 :   32);c==0163&&!(m[x][y+1]&16)?y++:   0;c ==   119         &&!         (m[                                       x][ y-   1]&   16)   ?y--:0;;c   ==97  &&!(m[x-1][y]&16)?x--:0;c==100&&!(m[x+1 ][   y]&   16)         ? x   ++:0             ;if(                    c== 3-   1+1   ){endwin(   );;   return(0)  ;}x   -a<5?a>S-   5?a-=S-5:(a=0):0;x               -a>         S-5?a<255   -S*         2?a               +=S-5:(a=256-S):0;   y-b<5?b>L-5?b-=L-5:(b   =0)   :0;   y-b>L-5?b<255-L   *2?b+=                                       L-5   :(b                     =256-L)   :0;e(x,y);if(m[x][y]&64)break;}while((c=getch())!=-1);endwin();cu(Q);printf(Q,v);}

Notice from BuffaloHELP:
Entered CODE tags.

Edited by BuffaloHELP (see edit history)

Share this post


Link to post
Share on other sites

And this one also ...more details you can get here link

           /*                                     ,*/            #include                              <time.h>             #include/*                     _  ,o*/  <stdlib.h>             #define  cŠ/*     -      . */return      ( C); /*    2004*/              #include   <stdio.h>/*.   Moekan           "'   `\b-'     */                typedef/*  */char   p;p* u                     ,w       [9                  ][128] ,*v;typedef  int _;_   R,i,N,I,A               ,m,o,e             [9],  a[256],k    [9], n[               256];FILE*f      ;_ x   (_ K,_ r        ,_ q){;   for(;                                         r<     q   ; K       =((     0xffffff)   &(K>>8))^                                        n[255     &        ( K   ^u[0        +                                     r  ++      ]     )]);c          (K  )}        _ E                           (p*r,    p*q  ){     c(          f         =          fopen                     (r  ,q))}_   B(_ q){c(    fseek        (f,      0        ,q))}_ D(){c(  fclose(f ))}_  C(  p    *q){c(  0-    puts(q    )   )}_/*   /      */main(_ t,p**z){if(t<4)c(   C("<in"       "file>"    "\40<l"   "a"  "yout> "     /*b9213272*/"<outfile>"   ) )u=0;i=I=(E(z[1],"rb")) ?B(2)?0 :   (((o   =ftell    (f))>=8)?(u     =(p*)malloc(o))?B(0)?0:!fread(u,o,1,f):0:0)?0:  D():0     ;if(   !u)c(C("      bad\40input  "));if(E(z[2],"rb" )){for(N=-1;256> i;n[i++] =-1   )a[   i]=0;       for(i=I=0;   i<o&&(R  =fgetc(   f))>-1;i++)++a[R] ?(R==N)?( ++I>7)?(n[  N]+1       )?0:(n [N   ]=i-7):0:   (N=R)    |(I=1):0;A =-1;N=o+1;for(i=33;i<127;i++  )(        n[i   ]+  1&&N>a[i])?    N= a     [A=i]     :0;B(i=I=0);if(A+1)for(N=n[A]; I<       8&&   (R  =fgetc(f ))>    -1&& i   <o       ;i++)(i<N||i>N+7)?(R==A)?((*w[I ]             =u [i])?1:(*w[I]=   46))?(a             [I++]=i):0:0:0;D();}if(I<1)c(C(              "  bad\40la" "yout  "))for(i            =0;256>(R=  i);n[i++]=R)for(A=8;             A  >0;A --)   R  = ( (R&1)==0)          ?(unsigned int)R>>(01):((unsigned            /*kero  Q'        ,KSS  */)R>>         1)^        0xedb88320;m=a[I-1];a[I            ]=(m           <N)?(m=   N+8):        ++        m;for(i=00;i<I;e[i++]=0){           v=w         [i]+1;for(R                      =33;127  >R;R++)if(R-47&&R-92           &&       R-(_)* w[i])*(                   v++)=    (p)R;*v=0;}for(sprintf                  /*'_  G*/  (*w+1,              "%0"     "8x",x(R=time(i=0),m,o)^~                0)  ;i<       8;++           i)u      [N+ i]=*(*w+i+1);for(*k=x(~                  0,i=0     ,*a);i>-        1;      ){for (A=i;A<I;A++){u[+a [ A]                ]=w[A       ][e[A]] ;     k     [A+1]=x (k[A],a[A],a[A+1]              );}if     (R==k[I])      c(      (E(z[3  ],"wb+"))?fwrite(             /* */   u,o,1,f)?D          ()|C("  \n    OK."):0    :C(            "  \n  WriteError"            ))  for  (i  =+I-           1 ;i >-1?!w[i][++                 e[+ i]]:0;             ) for( A=+i--;                 A<I;e[A++]             =0); (i <I-4                 )?putchar             ((_   )  46)                  | fflush            /*'      ,*/                  ( stdout            ):       0&                    0;}c(C           ("       \n                   fail")           )      /*                    dP' /                 dP                    pd  '                '                      zc                                      */                                     }

Notice from BuffaloHELP:
Entered CODE tags. Warning! Refrain from double posting especially when you copy and paste. It may be considered spamming.

Edited by BuffaloHELP (see edit history)

Share this post


Link to post
Share on other sites

Thanks nagu, actually I could not remember the exact name of the contest. Now I remeber - "International Obfuscated Code contest".btw, it would be better if you put your code within the CODE block, using BBCodes.It improves readability and also the emoticons do not come up at unexpected places within the code.Cheers.

Share this post


Link to post
Share on other sites

sure from the next time i will do the same. i didnt expect it, also since i could not delete the post, i left it as it is as i dont want to post one more time.

Share this post


Link to post
Share on other sites

#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;# ){n\l]!/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(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);}

141608[/snapback]

This process is actually similar to how zip software works. It narrows down to the most repeating group sequence and places a numeric value to repeat in a certain order. And then follow the same procedure with the next most repeating group sequence. I have never seen someone actually write that in C, however. Exciting!

Share this post


Link to post
Share on other sites

hey, I did not know that bit about zip software, though I know a few compression algorithms and the most basic one being huffman coding...

btw I was going through the official website of the contest and found new program submissions which were amazing.. could not believe what people cound pack in a C program with less than 4K characters(that is the limit of program for submission)..

    2) The size of your program source must be <= 4096 bytes in length.      The number of characters excluding whitespace (tab, space,
      newline, formfeed, return), and excluding any ; { or } immediately
      followed by whitespace or end of file, must be <= 2048.


A few of the entries created graphics not easily made even in photoshop.... maybe comparing a bit too far.. but u need to see it to believe it...

Also I suppose the contest is currently open, anyone interested...???

Their website as nagu gave is: http://www.ioccc.org/

Cheers.

Share this post


Link to post
Share on other sites

WOW, that was brilliant. Although it looks an awful lot like the linux source code... hmm... getting fishy. Cse-icons, you should try out for it (after all, aren't you the one always sending the C riddles?). Watch me cook up something in a week.

Share this post


Link to post
Share on other sites

hey, I did not know that bit about zip software, though I know a few compression algorithms and the most basic one being huffman coding...

142193[/snapback]

Zip software is amazing riddles of numbering and sequencing. Now, I am not perfectly clear either but as I understand it, this is how the zip software works (and much like the code for 12 days of Christmas).

 

Let?s take the following lyrics only:

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.

I have color coordinated them to show you the ?group sequence? as I have explained in my post (read it here). As you can see, it becomes bit more clear what group sequence means. So then I would assign

day of Christmas my true love gave to me (3, 7) because it appears at the 3rd and 7th position

a partridge in a pear tree. (4, 12)

on the (1, 5)

first (2)

second (6)

two (8)

turtle (9)

doves (10)

and (11)

And the group of 12 is now a list group of 9. Well you get the idea. Imagine if the software can figure out how many time the letter ?a? repeats and sees the pattern, I?m sure this will cut down even more.

 

So in a nut shell, this is how your zip software works?but faster and with better sequencing to reduce the size.

Edited by BuffaloHELP (see edit history)

Share this post


Link to post
Share on other sites

WOW, that was brilliant. Although it looks an awful lot like the linux source code... hmm... getting fishy. Cse-icons, you should try out for it (after all, aren't you the one always sending the C riddles?). Watch me cook up something in a week.

142742[/snapback]


Thanks osknockout, I thought abt contesting but the competition is damn good.. Also dont have much time on my hands now.. may be next time... but even looking at the winning entries gives a lot of new ideas and understanding of the quality of brilliant people out there...

 

Cheers.

Share this post


Link to post
Share on other sites

You're welcome cse-icons. Hey I have an idea for you. You should make a random C/C++ riddle program. That way we can be confused both ways and you'll probably get some real recognition. Looks like my dev. computer shut down... bummer. Make that week a month.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.