Fun Stuff

Obfuscate: a. To render obscure.
b. To darken.
[latin. obfuscare, to darken]


Obfuscated greetings

What are the strange hieroglyphics on the verifaction mugs?
They are programs, written in the spirit of the IOCCC
(The International Obfuscated C Code Contest).
The overall winner is whoever produces the most unreadable,
creative, and bizarre (but working) C program; various other prizes
are awarded at the judges' whim. C's terse syntax and
macro-preprocessor facilities give contestants a lot of room to
maneuvre. The winning programs often manage to be simultaneously
(a) funny, (b) breathtaking works of art, and
(c) horrible examples of how not to code in C.

On this page you'll find examples of obfuscated code written by
verifactionites in both C and perl.
All the programs on this page can be cut and pasted into your
favourite C compiler or perl interpreter, to produce amusing
yet completely useless output.

                
#include <curses.h>

                    int
                    S,u
                   ;n(O,
                   B,a,b)
                  {O<0||O>
                 u-1||B<0||
                B>S-1?0&01:
               mvaddch(O,B,a|
              COLOR_PAIR(b-2?2
             :7)|(b?A_BOLD:0));
            }c(d,e){return d+rand
           ()%e;}main(){int f[8<<
          10],*R,A,I,N,B,O,W,g,h,i[8
         <<16],j=8<<7,k=19,l[8<<10],*
        m;initscr();savetty();nodelay(
       stdscr,1);curs_set(0);noecho();
       start_color();use_default_colors();
      init_pair(2,2,-1);init_pair(7,7,-1);
     for(N=0;N<8<<16;N++)*(i+N)=32;for(N=0;l
     [N]=-c(1,256),N<8<<10;N++)f[N]=0;while(
    refresh(),napms(31),wgetch(stdscr)-27){for
    (B=0;u=LINES,S=COLS,m=l+B,B<S;B+=2)if(*m>0
    )*m=*m>1?*m-1:-c(40,256);else if(!++*m){*m=
   c(10,32);W=(c(0,k))?0:(*m+=10);for(R=f;*R&&(*
   R+1); R+=7){}*R++=*m;*R++=0;*R++=B;*R++=0;*R
   ++=W? c(1,u):999;*R++=W?4:c(1,4);*R++=c(2,9);
   }for(  R=f;*R;R+=7)if(*R!=-1)if(B=*(R+2),O=*(
   R+3),   g=*(R+4),(*(R+1))++==*(R+5)){if(*(R+3
    )=++O   ,*(R+1)=0,n(O,B,i[O+B*j]=c(33,93),2
     ),h=O    -g-1,h>=0&&h<11)n(O-1,B,"wfsjgBd"
     "ujpo"     [h]-1,2);for(A=0,I=*(R+6);I>0;
      I--,A=        *(R+6)/3>I?2:1)O-I<g||O-I
       -g>9+1?         n(O-I,B,i[O-I+B*j],A):
        0;if(n(O         -*R,B,i[O-*R+B*j]=
          32,0),O-*    R>u)*R=-1;}else n(
             O,B,i[O+B*j]=c(33,93),2);}
                curs_set(1);resetty(
                     );endwin();}













$ cc rain.c -o rain -lcurses
$ ./rain

       
Click for larger version
Click picture for larger version
                
                 main(i
             ,z){float a[
           32],b=3,c;for(c=i=
         0;i<32;)a[i++]=2;for(z
        =590;z--;a[0]+=(a[0]>78||
       a[0]<2)?b=-b*.9:b,a[1]=(a[
       1]+(c+=0.2)>22)?c=-c*.999,
       22:a[1]+c)for(i=31;i;a[i]=
       i-1?a[i-2]:a[i],i--)if(i%2
        )printf("\033[%d;%dH%c"
         "\n",(int)a[i],(int)a[
           i-1],1^"Awdshg@bu"
             "hno///!"[i/2
                  ]);}
       
Click for larger version
Click picture for larger version
                                   main(f,u,n){for(u=n=9;n+11
                                     ;) putchar(--u+29?(u-16)
                                       /15||n/9?(u*u/3+n*n
                                         -30)/12?32:37:1^
                                          "dshg@buhnoAw"
                                           [f++%12]:(u
                                            =50,n--,
                                             10 ))
                                              ;}
triangle
                       main(
                      w,h,a,t
                      ){int x
                       [1680
         ],y[
         1680]
         ;for(        h=0; h<       1680;y[h
         ++]=0         );for     (;;w++){for     (h=0;h<
         1680;         h++)x     [h]=w          -1?w%20?h/
         9-97?         y[h]:     1:y[h         ]:0;    puts(
         "\033"        "[H")     ;for(         h=71;   h+0<
         1610;         h++){     for(t=a=0;a   <3;a    ++)t
         +=x[h         +69+a     ]+x[h+a-71]   +(a-1?x[h+a-
         1]:0)         ;y[h]     =x[h]         ?t<2?
         0:t>3         ?0:x[     h]:t-         3?x[h
         ]:1;putchar   (h%70     ?y[h]          ?1^"dshg"
         "@bhnoAw"[h  %12]:32    :10);           }delay(100);    }}
Click for larger version
Click picture for larger version
char *z="\ACGT\000\

            CG\
            T--A\
            C---G\
            G----C\
             C----G\
              G---C\
               C--G\
                CG\
                GC\
               A--T\
              T---A\
             C----G\
            G----C\
            C---G\
            C--G\
             GC\
             CG\
            G--C\
            C---G\
            G----C\
             C----G\
              A---T\
               A--T\
                CG\
                GC\
               C--G\
              T---A\
             A----T\
            G----C\
            A---T\
            G--C\
             TA\
             CG\
            G--C\
            G---C\
            C----G\
             C----G\
              G---C\
               T--A\
                TA\
                GC\
               C--G\
              A---T\
             C----G"
            ;main(n
            ){char
            *c=z+
             4;int
              i=0,p
               =0,t=0
               ;while(
               *++c){
              for(n=
              0;z[
              n]
             &&
            z[n]
            !=*c;n
            ++);if
            (n-4&&
             (i/16
              %2+
               i++
               +1)%
              2)if(
             t=t*4+
            n,++p%
            4==0)
            {putchar
            (t);t=0
              ;}}}
DNA
                                             //                                 .
                                            main                               (
                                            T,u,x                             )
                                           {x=0;                             //
                                          while(u=                          //
                                         "iLiLbLd+"                        //.
                                        "ZOiLiLaL["                       //
                                        "cLa+(OiLiL"                     "L"
                                       "[cL[bLVOiLiL"                   "["
                                      "eL(OiLgLiVVOi"                  "L"
                                     "hLHfLHOiLhLHT;U"                 //
                                     "LT;UHOiLhLHTdLUH"               "O"
                                    "iLhLHL(b+[LHOiLhL"              "H"
                                   "fLHOiLgLa[JdLJa(OiL"            "f"
                                  "La[aLxuz!"  "$aLa(Oi"           "L"
                                 "dL+a[\"1>"   "52m/@5;:"         "a("
                                "+OiLcLTLa"     "(iLLa[LU"       "Oi"
                                "LcL[aL(U"       "h+T[aL("      "Oi"
                               "LcL(bL("          "h+[bL[O"    "iL"
                              "cLTc+Uf"           "LTc+UaO"   "\"1"
                             ">52m/@5"             ";:LbZL3" "5B5"
                            ":3LE;AL"               "?<->7L-:0L8"
                            "534@L5"                 ":L^a\\FMa"
                           "LaOL"[x                  ++]){if(u
                          >=97&&u                     <=105)T=u
                         -95   ;                       else{u=
                        (u+20)%                         96+32
                        ;while                          (T--
                       >=1)//                            VX/
                      printf                              (
                     "%c",
                     (u-
                    35?(
                   u-//
                  122?
                 u:53
                ):10
                ))
               ;T
              =1
             ;}
            }}
           //
            
Bolt
                 #
$_
="00
V6960T
42363340
T222225222
220T21412521
4120T34353430U
8780X3:30WC0SK0O
966680<5;=393247;3
0;966191:242325680;3
1725353214331;351;0173
35856574;58434701=756847
371455631:0779557752363358
80:28;245325236229740CA69337
=0B487674337740B38C6<930B3835G
35730854383<:<3835406>83R38>0542
7:4Q39923042G3P3E20G9P50E:R:0E7W80
0";for(
$v=32;s
/.\s*//;$v=$w?$v
^96:32){$w=ord()
-48;print$w?chr
($v)x$w:"\n";}

FSM?
Click for larger version
Click picture for larger version