For a translation of this page into Bulgarian, see www.fatcow.com/edu/sig-prog-bl.
/* _ */main(int k,char**n){char*i=k&1?"+L*;99,RU[,RUo+BeKAA+BECACJ+CAACA" /* / ` */"CD+LBCACJ*":1[n],j,l=!k,m;do for(m=*i-48,j=l?m/k:m%k;m>>7?k=1<<m+ /* | */8,!l&&puts(&l)**&l:j--;printf(" \0_/"+l));while((l^=3)||l[++i]);} /* \_,hris Brown -- All opinions expressed are probably wrong. */He wrote this one by himself. Some older ones by him are:
main(){char*i="L0[B0BCA7G0BFACIW0BfRAAB0BCACAFR0[BCAFE0LCCAFR0",j,k=0;for(;*i; *++i==48&&puts(""))do for(j=*i-48>>k&7;j--;)putchar(k+32);while(k^=3);} /**i="ADD08:::::08:::::08:::::08:::::08:R::08::;9:08::D:08:j:08:7<0997<0jh0"*/And derived from the above:
main(){char*i="ADD08:::::08:::::08:::::08:::::08:R::08::;9:08::D:08:j:08:7<0997<0jh0", j,k=0;for(;*i;*++i==48&&puts(""))do for(j=*i-48>>k&7;j--;)putchar(k+32);while(k^=3);}
/* <xxxxxxxx@xxx.xxx.xx> | Use gcc <signature> to guess my full name */ main(){char s[]=".bg`z`lE)gc`}{hD-|\\/OI:retteL>\n\n",k;long w=32,r,_,y ,i,b,g,p[]={63l<<16,37968,15,32,896,2048,24576,37449,2,12546,3074,19138 ,3586,585,0},t;b=g=r=0;while((b<7)&&(g<65278)){for(_=16;_+10;)putchar(_ -->0?_&7?g>>_&1?s[_]^9:46:w:s[_+w]);while((k=getchar())<65);for(_=15,t= g;_;)if((s[_--]^9|w)==(k|w))g|=2<<_;if(t==g)r|=p[b++];for(y=9,t=0;y--;) for(_=9;_;)putchar(--_?(i=p[y+6]>>24-3*_&7)?r>>t++&1?s[i+15]:w:w:10);}}
int a=10000,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;for(;d=0,g=c*2;c -=14,printf("%.4d",e+d/a),e=d%a)for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);}He also wrote one for calculating the first 15,000 digits:
a[52514],b,c=52514,d,e,f=1e4,g,h;main(){for(;b=c-=14;h=printf("%04d", e+d/f))for(e=d%=f;g=--b*2;d/=g)d=d*b+f*(h?a[b]:f/5),a[b]=d%--g;}For some background information, read Unbounded Spigot Algorithms for the Digits of Pi. (And even shorter.)
/* Marcel van Kervinck <xxxxxxx@xxxxx.xxx.xxx.xx> */ t(a,b,c){int d=0,e=a&~b&~c,f=1;if(a)for(f=0;d=(e-=d)&-e;f+=t(a-d,(b+d)*2,( c+d)/2));return f;}main(q){scanf("%d",&q);printf("%d\n",t(~(~0<<q),0,0));}When the program is run, one has to give a number
n
(smaller than 32), and
the program will return in how many ways n
Queens can be put
on a n
by n
board in such a way that they cannot beat
each other.
Note that the d=(e-=d)&-e;
statement can be compiled wrong
on certain compilers. The inner assignment should be executed first.
Otherwise replace it with e-=d,d=e&-e;
.
#define X "Happy birthday to you\n" main(){printf(X X"%.15sdear YourName\n"X,X);}
Weighing in at 73+N characters, this was the winner of an informal
competition to find the smallest C program to print the Happy Birthday
song for someone whose name is N
characters long. If you're
interested in the details, ask Tom
Magliery.
"main() {printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}" -- David Korn, AT&T Bell LabsUsed by Bill W. Kelly.
xxxxxxxx@xxxxx.xxx.xx (Risto Paasivirta). char a[1761],*b;main(){int c,k;double d,e=1.111,x,y,z,sin(),cos();for(b=a, c=1760;*b++=' ',--c;);for(d=.1;d<=1.3;d+=.2)for((y=d,x=0.0,c=150);c--;){z= x*cos(e)-(y-x*x)*sin(e);y=x*sin(e)+(y-x*x)*cos(e);x=z;k=x*20.0+40+((int)(- y*10.0+11))*80;if(k>=0&&k<1761)a[k]='*';}puts(a);}A Pi calculating program:
/* Risto Paasivirta, xxxxxxxx@xxx.xx (130.234.0.6) */int a[33235],*b=a,c=1e4,d= 33234,e,f,g=0,h,i;main(){for(e=d;e--;*b++=2);*b=4;for(e=2501;e--;printf("%04d", h))for(b=a+d,f=d;f>-1;g*=f--){i=*b*c+g;h=f?2*f+1:c;g=i/h;*b--=i%h;h=g;}}(Remark: This program takes some time to complete.)
/* xxxxxxx@xxxxx.xxx.xxx (192.74.137.5) */ /* Joseph H. Allen */ int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0) +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2 ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n","#"[!a[q-1]]);}
-------------------------+ #include <stdio.h> /* BC ok , Apollo NFG */ Real Gagnon, | int main(void) { int i=0; Universite de Montreal | while(putchar(i++["\13Dl~fxym789\26xd"]-i)); xxxxxxx@xxx.xxxxxxxxx.xx | while(putchar((--i)["\0\t+*)('&%$#\"\1"]+i));}
r(_,i){return putchar(!i?_:' '),i?r(_,--i):(putchar('\r'),_);}main(_){return _ ==' '?_:r(main(_+_/_),_)^_["];!aL#3%17t\211N,=<je\42f\227`&!&-8\42~/KK"]-'!';}
char c[160],z;main(x,d){for/*/ Brendan McKeon /*/(x=159;x-- ;c[x]=32);c[79]=z;c[39]=88/*/ xxxxxxx@xxxx.xxx.xx /*/;for(d=31;x =78,puts(c+z),d--;z=80-z)/*/ http://alf2.tcd.ie/~bmckeon /*/for(;--x;c[x +80-z]=88-56*!(c[z-!0+x]/*/ 4th Yr. 'Comp Sci' 'Student'/*/-c[z+x+1]));}
main(o,O0)char**O0;{int OO,O;O=--o?atoi(O0[!0]):! 0;for(o=((OO=O*O)-O+!0+!0)>>!0;OO;o+=((--OO%O)?-! 0:((((o-!0)%O)?O:0)+!0))-(((o-!0)%O)?O:0)){printf ("\n%*d "+!!(OO%O),!0<<!0<<!0,o+=(o<!0)?O*O:0);}}
int n;main(i,m)char**m;{while(--i)n^=atoi(m[i]); while(*++m)if((n^atoi(*m))<atoi(*m)||atoi(*m)*!n ){printf("%d\n",(n^atoi(*m))-!n);while(*++m)puts (*m);m--;}else puts(*m);} /* play: nim <nums> */
Michael Schroeder main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}He also wrote:
/* Convex Administration xxxxxxxxxxxx@xxxx.xxxxxxxxxxxx.xx | |__RRZE____________________________________________________*/ main(_){char*x="=#6#694.21..#62.*.*2-)1#62.*..*.=#=1..29..#"; while(_=*x/4)_-=8,printf("\n%*s"+!!_,_+_,"_/_/_/"+*x++%4*2);}He also wrote a another signature program.
v,i,j,k,l,s,a[99]; main() { for(scanf("%d",&s);*a-s;v=a[j*=v]-a[i],k=i<s,j+=(v=j<s&&(!k&&!!printf(2+"\n\n%c" -(!l<<!j),"#Q"[l^v?(l^j)&1:2])&&++l||a[i]<s&&v&&v-i+j&&v+i-j))&&!(l%=s),v||(i==j ?a[i+=k]=0:++a[i])>=s*k&&++a[--i]);} /* Osovlanski and Nissenbaum */Origin unknown. Submitted by Charles Richmond. Seems to be broken.
char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C); -- E; J[ E] =T [E ]= E) printf("._"); for(;(A-=Z=!Z) || (printf("\n|" ) , A = 39 ,C -- ) ; Z || printf (M ))M[Z]=Z[A-(E =A[J-Z])&&!C & A == T[ A] |6<<11<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}Note that the constant 11 assumes a 15-bit random number generator, and needs to be replaced with 27 if rand() produces 31-bit numbers instead.
See his Programming Pearls page for more. There is a Obfuscated Tetris program of only 1467 characters (just a little too long for a signature).
See also his Yin-Yang signature.
main(int c,char **v){long x;while(--c){sscanf(*++v,"%li",&x); printf("Decimal = %ld Hex = 0x%lx octal = 0%lo\n",x,x,x);}}Args are hex or dec or oct output is hex and dec and oct.
A recent signature program by him is:
int g(int g){putchar(g);}main(){int c=c==c,h=-~c,a=h+h,*r=(int*)gmtime(&c)+a; char*t,i,m,e;*r++=++a,*r=h+c<<h+h;a=mktime(r-a);t=(char*)ctime(&a);i=g(*t+*(t -~h));m=g(*++t-(h<<h));e=g(*++t-c);g(*t+h);g(*++t<<c);g(i);g(m);g(e);g(*--t+h );e=g(*r-h);g(*t-h);g(*--t+~h*h);g(e);g(g(*t)-(e=(h<<h)+h));g(e);puts(--t);}His explaination is:
Of course it won't pass -Wall or any lint checks but hey! it works on HP-UX and Linux. Apparently if you try it on a PC running a MicroSquish OS it fails with "program too big to run" (HELLO!!!)
The program prints my email address and Date of birth. (Note:- the time is wrong. But I don't know that anyway.)
The program has NO Literals, NO Numbers and it doesn't require any input from the user apart from compiling and running the program. So I think that it starts with nothing. I've used the minimum number of different chars. I think that there are only 29 different characters in the source including newline and space.
He also wrote a C and COBOL polygot signature program.
main(x,y/* Patrik Lundin | xxxxxx@xxxx.xxxx.xx */){for(;x++;) for(y=2/* Docentv. 28 | xxxxxxx@xx.xxxx.xx */;x%y;)printf( ++y/x+/* 977 52 Luleaa | http://www.ludd.luth.se/~lundin */"\0%d\n",x);}
A morse coder:
main(a,b){for(;a=223&getchar()+1;putchar(32))if(a>64&a<92)for(b=0,a= "Xzjtpnd~xFTvHhDfRl|P\\^LZJr"[a-66];(a/=2)>1;b+=a%2)b&&putchar(45+a%2);}
A morse decode:
main(c,r){for(r=0;c=getchar()+1;r=c-33&&c-11?r+r+1+(c <47):putchar(" etianmsurwdkgohvf-l-pjbxcyzq"[r])*0);}
A number factorizer:
main(i,c){for(scanf("%d",&c);1<(c/=i);printf("%d\n",i))for(i=1;c%++i;);}For more see his Obfuscated C page.
Bruno Van Wilder Royal Holloway, University of London main(int n,char**a){for(n=0;putchar(a[2][n]?(a[2][n]%32+(**a%2*2-1)* (a[1][n++%(a[2]-a[1]-1)]%32-1)+25)%26+97:10)-10;);} (Vigenere encryption/decryption)
/* xxxxxxx@xxx.xxx.xx */ main(){char*c="2$$,$$2CD$45$$,$$5(D$4%$$,$$%(D$4%J\ */K*%(K,K2MMPL%2HLH,4LLLL$4HLF$4RLLS$4HL%;5MLLD$5HL&<5MLPL$5HLHL2R,/K$2(K,+"; int _=0,__,K;for(;_<10;_++){for(__=0;__<11;__++)for(K=0;K<6;)putchar(c[11*_+\ __]-36&1<<K++&&__*6+K<65?'#':' ');putchar(10);}} /*ATARI Falcon030 */
------ /* cc signature.c -lm */ main(){int i,j,k,l;for(i=-12;i<13;i++,printf("\e[H")){for(l=141596885; l>8;l>>=4)p(97-(l>>22)+(l&15));for(j=-12;j<12;){for(k=j+12?-12:-6;12>k ;)p((l=k*k+++i*i+j*j)<144?(l=sqrt(l))[".,:;iIJYVSOM"]:32);j++<11?p(10) :0;}}puts("Elijah: xxxxxxxx@xx.xxxxxx.xxx");}p(int m){printf("%c",m);}and (for St. Patrick's Day):
-- /* if(TERM==ANSI) {cc -Dc=`"\e[32m"` sig.c} else {cc -Dc=\"\" sig.c} */ e(int d){printf("%c",d);}main(){int a=0,b;for(b=141596885;b>8;b>>=4)e(97-( b>>22)+(b&15));puts(c);for(;a<128;){b="}////+c)cy////*494y////*979y///+e*" "959*ey///*I5Q*939*I5Qy///*96bI3Qb69y///*!777!y///*Y6kIql6Yy///*A5q+9!,A5" "9y///+m,YQ-my////-iq~y"[a++];for(;7&b;e("Eli!: MV?JL1m\"P\n"[b-->>3]));}}
Full raytracer (name printed, wide, -lm, 73 columns):
main(c){float x,y=-2,a;for(;2>(y+=.2);puts(""))for(x=-4;4>(x+=.1);printf( "%c","MHRXY]i:' "[9>a?(c=21+8*(x-y-7)/a*(3-sqrt(9-a)))>0?c:0:y<1?9:((c=98 -1.2*x/y)&1^1&(c=-4.8/y))+(a=4*(x-7)+17*y,a*a/81<x*x+16+9*y*y-24*y)<<2])) a=8+x*x/2+y*y/2;puts("Andrew Garrard - xxxxxxxxxx@xxxxxxx.xxxxx.xx.xx");}Full raytracer (3 lines of code because some compilers need the include, no name, wide, -lm, 79 columns):
#include <math.h> /* Andrew Garrard - xxxxxxxxxx@xxxxxxx.xxxxx.xx.xx */ main(c){float x,y=-2,a;for(;2>(y+=.2);puts(""))for(x=-4;4>(x+=.1);printf("%c", "MHRXY]i:' "[a<9?(c=21+8*(x-y-7)/a*(3-sqrt(9-a)))>0?c:0:y<1?9:((c=98-x*1.2/y)&1 ^1&(c=-4.8/y))+(a=4*(x-7)+17*y,a*a/81<x*x+16+9*y*y-24*y)<<2]))a=8+x*x/2+y*y/2;}Julia (time dependent, narrow, -lm, doesn't work on Norcroft):
/* o._.o Andrew Garrard - xxxxxxtxxx@xxxxxxx.xxxxx.xx.xx */#include <time.h> /* ((^)) */main(c){float x,y=2,X,Y,Z,q,t;q=sin(time(0))*1.3;t=sqrt(1.69-q*q); /* O)_(O */for(;(x=-2)<(y-=.1);puts(""))for(;Y=y,(X=x+=.05)<2;c=printf("%c",c /* O/ \O */[" .-:|O8H#"]))for(;X*X+Y*Y<4&&++c<8;Z=q+X*X-Y*Y,Y=2*X*Y+t,X=Z);}Perihelion (mildly obfuscated):
/* ___ */int x=-1;int f(){return x+++1&&("MX+###'$##TYC78%##3$##-K`5,##C&" /* (/. .\) */"#[PB##&S$#?&WG<P.L)D++%<-%K)T($MC+TI70YL.MGEAM#<Y(9K.MG:C03;LK." /* \(T)/ */"OPFW3,L1:MNW5=KWb=&DX5MNWY15X=]aBM96bLG7]R@''Y(Zb&%^EbCSQ$$bP,/" /* O~ ~O */"==1J)0J)<1>"[x/6])-35&1<<x%6;}main(y){return y-440&&printf("%s", /* ()-() */" \0\\\0|\0/\0.\0'\0_\0\n\0[\0[]\0:_:\0[ |\0 || \x00[__] \0__\0" /* Andrew */"'.__.'\0"+(f()?f()?f()?29:f()?8:f()?35:f()?44:f()?21:f()?16:18:f /* Garrard */()?f()?f()?6:14:f()?41:f()?2:25:f()?4:f()?12:10:0))&&main(++y);}Perihelion (my bear):
/* .O_ */int y=0,x=-1;int f(){x++;return("MX+###'$##TYC78%##3$##-K`5,##C" /*: .\__ */"&#[PB##&S$#?&WG<P.L)D++%<-%K)T($MC+TI70YL.MGEAM#<Y(9K.MG:C03;L" /*O.(4) _() */"K.OPFW3,L1:MNW5=KWb=&DX5MNWY15X=]aBM96bLG7]R@''Y(Zb&%^EbCSQ$$b" /* \_ .''.\_ */"P,/==1J)0J)<1>"[x/6])-35&1<<x%6;}main(){for(y=0;y++<439;)printf /* / '..'__()*/("%s"," \0\\\0|\0/\0.\0'\0_\0\n\0[\0[]\0:_:\0[ |\0 || \0[__] " /* ()/\____() */"\0__\0'.__.'\0"+(f()?f()?f()?29:f()?8:f()?35:f()?44:f()?21:f() /* Fluppeteer */?16:18:f()?f()?f()?6:14:f()?41:f()?2:25:f()?4:f()?12:10:0));}Christmas tree (short but unintelligible):
/* _ *//* Andrew Garrard */int y,z;main(x){x=(x>0?-9:x);z=((z=(x+5) /* /:^/ \_/))*/)>0?z:-z);printf(!x&&++y?"\n":z?z>y%3+y/3?" ":x<-5?"/":"\\": /**<_o_(\__// */y?"|":"*");y-9?main(++x):puts(" _|_|_")&&puts(" \\___/");} /* D-|\O *//* A party animal is for life ... not just for Christmas. */Christmas tree (cute but long):
/* * Andrew Garrard - xxxxxexxxx@xxxxx.xx.xx */ /* /_\ */int y,z;main(x){x=(x>0?-9:x);z=((z=(x+5) /* o. .o */)>0?z:-z);printf(!x&&++y?"\n":z?z>y%3+y/ /* ((Y)) */3?" ":x<-5?"/":"\\":y?"|":"*");y-9?main( /* ()) (() */++x):puts(" _|_|_")&&puts(" \\___/");} /* ()^() A party animal isn't just for Christmas.*/Valentines (has broken Watcom, Norcroft, Dice and Lint so far...):
/* db.db Andrew Garrard */int x,y,X;Q(Z,Y){Y=y<16?X=x-30,Y=y-17,225>X*X+Y */* `888' */Y:x>y,y+=y%2*2*(!(x+=y&x==39?-x:y&1)-1)+1;return Z?Y+2*Q(--Z,-- X)/* `8' */:Y;}main(){for(;y-42;puts(""))M(y);}M(z){printf("%c",(printf("%" "c"," ',""[`~/P.\\wb]9dM"[z=Q(3,7)]),x&&M(*""),z)[" `.]'~\\9,/wd[PbM\""]);}Life... don't talk to me about life (or Get a life, depending...):
long l=17895696,p,m[8],n[8]={0,65536,4096,1118208},y,z;main(x){for(;p++^14; ){for(;puts(""),y<8;++y)for(x=7;x--;printf("%c",".#"[1&n[y]>>4*x]));for(;++ x<7;m[x]-=n[x],m[x]=((m[x]/8|m[x]/4)&l^l)&m[x]/2&(m[x]|n[x]))for(m[x]=0,y=4 ;--y;m[x]+=z*17+z/16)z=n[x+y-2];for(;--x;n[x]=m[x]);}} /* Andrew Garrard */He has some more longer signature programs.
main(g,h){for(;h=getchar(),h>=0;putchar(g<65||g>90?h:g<78?h+13:h-13))g=h&223;}A program which generates 2569 decimals of e:
main(i){int j,s,d[1001];for(i=1e3;i;)d[i--]=1;for(printf("e>2.");++/*R.Harley*/ i<429;printf("%06d",s))for(s=0,j=1e3;j>1;d[j]=s%j,s/=j--)s+=1e6*d[j];puts("");}
He also wrote A Mandelbrot fractal in .pgm format signature.
Program which prints a solution of the Eight Queens problem:
q(a,b,c){int e,f,i=8;for(;a&&i--;)if(e=1<<i,f=e<<a|e<<24-a,!(b&e||/*R. Harley*/ c&f)&&q(a-1,b|e,c|f))return printf("%08x\n",1<<i*4);return!a;}main(){q(8,0,0);}
main( M,e,r,l,y,n )char**e;{for(l=atoi(e[1])/10*80-atoi(e[2])/5-836;r="\ @Q@t@ L,e,R,o,y NKACLCCGZAAQBEAADAFaISADJABBA^SNLGAQABDAXIMBAACTBATAH\ DBANZ ----------- cEMMCCCCAAhEIJFAEAAABAfHJETBdFLDAANEfDNBPHdBcBBBEA_Ax" [M++-3];)for(;r-->64;)putchar(!l+++33^M&1);}/*Run w/lat & long as arguments*/(By the way, he was the one who nominated me for the Geek Site of the Day.)
/* Martin Haring <xxxxxxxx@xxxxxx.xxxxxx.xx> || use gcc to play mastermind */ main(){int i=0,j,e,p,a[4],b;srand(time(0));for(;i<4;i++){a[i]=rand()%8;for(j= 0;j<i;j++)if(a[i]==a[j])i--;}printf("A B C D GP\n");do{system("stty cbreak"); e=p=0;for(i=0;i<4;i++){b=getchar()&7;printf(" ");if(b==a[i])p++;for(j=0;j<4;j ++)if(b==a[j])e++;}system("stty cooked");printf("%d%d\n",e-p,p);}while(p<4);}He also has a Perl version of this signature.
main(){while(!fork())sleep(1);}This simple one-line C-program included is a program that hide itself when it runs on a UNIX machine. You have some difficulties to kill it because it changes PID every second. Dario also wrote some self printing programs.
#define f(X,g,p,N,M)M{return X?a&b?a&b&1<<i&&m(b,a^1<<i,9)>8?i:M:0:9;}main(){\ int a=511,b=a,i=4;for(;X;b^=1<<N)a^=1<<g-'1',g,p(N+'1'),p('\n');} /* 123 */ f(i--&&b&7&&b&56&&b&448&&b&73&&b&146&&b&292&&b /* John Rickard */ /* 456 */ &273&&b&84,getchar(),putchar,m(b,a,9),m(a,b,i)) /* xxx@xxxx.xx.xx */ /* 789 */Moves are given by the number 1 to 9, according to layout given in the signature. This program does never lose, but sometimes fails to win, when it could have won.
/*--Chris--*/main(){char*s="NDDGNLALAPAEDIDBBBBPADDIDB@B@PALGGDLAJCPAD" /*Goldsmith*/"DED@BBBPAEDEDBBBBPNDDINLILIP",j;for(;*s;printf("\0\n"+((* /*---------*/s++&j)==j)))for(j=1;j<=8;j*=2)printf(" \0_/"+(*s&j?3:0));}
On unix: tail -2>sig.c;make sig;./sig <sig.c main(){int v=77+97*121+32,c=71+111/100*32;while(v&&98)if(scanf("%d",&v)+108== 101+8&&v+115>9+115)putchar(++v- 32*4+121- 111+117);else- 10+getchar()+0;}
char m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r; r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c== '+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(2,p,1),c-','||read(2,p,1));}(Eric Bock also wrote one.)
/* --==[ Anthony J. "Tony" Mills ]==-----==[ ????????????????? ]==-- */ T,M;main(){for(time(&M),M%=3;T=M["xzoifpzt\1\1\1"]-1;putchar(T,M+=3));}
+--------------------------------------------------------------------------+ | -- Sidney Cadot - xxxxxx@xx.xxx.xxxxxxx.xx - ITS/TU Delft - tst. 3850 -- | +--------------------------------------------------------------------------+ |/* C-code to calculate day-of-week (1901-2099). Type name for man page. */| |main(int c,char**v){exit(printf("%sday.\n","Use MM/DD/YYYY argument to c" | |"alculate week\0Mon\0/0/Tues\0/0Wednes\0Thurs\0/Fri\0/0/Satur\0/Sun"+(*++ | |v?42+((5*atoi(6+*v)+"@GSTDLXDP@HT@"[atoi(*v)])/4+atoi(3+*v))%7*7:0))/30);}| +--------------------------------------------------------------------------+
/* Eric */main(s,i,j,k,c){char*p=malloc(s=1),*a=p+(*p=i=j=k=0)/* Bock */ ;while(~(*a=getchar())&&(++a-p<s||(a=(p=realloc(p,s+s))+s)&&(s+=s))||(*a =0));for(a=malloc(s=1),*a=0;(c=p[i])&&(c=='+'&&++a[j]||c=='-'&&--a[j]||c =='>'&&(++j<s||(a=realloc(a,s+s))&&memset(a+s,0,s)&&(s+=s))||c=='<'&&j-- ||c=='.'&&~putchar(a[j])||c==','&&~(a[j]=getchar()))|!strchr("><.,",c);i ++)while((c=='['&&!a[j]||c==']'&&a[j])&&(k+=(p[i]=='[')-(p[i]==']'))&&p[ i+=c/* Brainf*** */=='[']&&(/* worse than */i-=c==']'/* this sig! */));}
#define P(C,X)case C:printf(#X);break; /* bftoc.c by xxxxx@xxxxx.xxx */ main(){int c;printf("char a[9999];main(){char*p=a;");while((c=getchar())>=0) {switch(c){P(62,p++;)P(60,p--;)P(43,++*p;)P(45,--*p;)P(46,putchar(*p);)P(44, *p=getchar();)P(91,while(*p){)P(93,});}}printf("exit(0);}");exit(0);}The program works like a pipe.
int i,j,d;main(){for(;i<25;i++)for(j=48;j;putchar(!j?10:" #"[(d<150&&d>81)||(d< 150&&(abs(24-j)<2||(i>12&&(abs(j-i-12)<2||abs(48-j-i-12)<2))))]))d=(24-j)*(25-( --j))+(12-i)*(12-i);}A yin-yang signature program:
int q,Q,w,z;_(o){w=q-10*o;z=Q-20;return w*w+z*z;}main(){for(;q<40;q+=!(Q%=40), putchar(!Q++?10:_(2)>400?32:".*"[w<0?(_(1)<99|z>0)&&_(1)>7:z>0&&_(3)>99||_(3)< 7]));}An prefix expression evaluator signature program:
#include<stdio.h>/* gcc sig.c; echo '(* (+ 2 5) 6)' | a.out * Mauro Persano */ c;x(){while(isspace(c=getchar()));}main(){printf("%d",y());}y(){int v,t,a,b;x( );c>47&&c<58?ungetc(c,stdin),scanf("%d",&v):c==40?x(),t=c-42,a=y(),b=y(),v=!t? a*b:t==1?a+b:t==3?a-b:t==5?a/b:exit(1),x(),c==41||exit(1):exit(1);return v;}
main(){int i,a,e[10]={255,137,129,129,0,255,25,41,70,128},s[16]={3,4,5,6, 6,6,5,4,3,2,1,0,0,0,1,2},n=0;while(1){puts("\e[2J\e[1;1H");for(i=0;i!=10; i++){for(a=s[(i+n)&0xF]+4;a!=0;a--)printf(" ");for(a=7;a>=0;a--){if(((e[i] >>a)&1)==1){printf("#");}else{printf(" ");}}puts();}n++;usleep(40000);}}
main(){int i,j;{printf("\n Who did you say ? Sierpinski ? \n");} for(i=0;i<80;i++){for(j=0;j<80;j++)printf("%c",i&j?'.':' ');printf("\n");} printf("\n Life is a beach - George Sand (1804-1876) \n\n"); return 0;}
char*t= "u]Gd\\wa[nc[eHEdBQbhb`hgHWRLSbYfaYeHAIPQbhb`heHQINwihnkh";int main(void) {int i=0,c;for(;i<330;c>>=1){if(i++%6==0)c=*t++;printf(i%66 ?"%c":"%c\n",c&1?'|':' ');}return printf("is a nice little thing\n");}
int C,e,d,r,i,c,L[10000],_=1e4,Q[4],O[4];o(){for(C=rand();L[++C,C%=e]; );}q(i,c){for(d=4;d--;i-=Q[d]==O[d]);for(;++d>16;)Q[d&3]==O[d/4]&Q[d&3 ]>=0?c+=Q[d&3]=O[d/4]=-1:0;return i|c;}F(c){printf("%04i%c",_?o(),C:-1 ,c);}main(n){for(e=_;_<1;)for(F(63),scanf("%i%i",&i,&c),n=e;n--;q(i,c+ i)?_-=!L[n]++:0)for(r=1,d=4;d--;r*=10)O[d]=C/r%10,Q[d]=n/r%10;F(46);}
int a,c,e,_[14]={0xf4364d42,1,54<<16,40<<16,50<<20,5<<20,1<<16,16};t(p ){fputc(p*c,a);}main(i){for(fwrite(_,1,54,a=fopen("a.bmp","wb"));64e3> i;t(4))e=i/16000*80+i%800/10,c=(i+i++/800)&1?("UEUJmbUiILefR]uQyrxruf\ VQ[JWUEjJaJuJBEkHU}_iDMnHi]Ldve@"[e/6]>>e%6)&1:i,t(6);}
char a[]="lbiitgt l e \n\n\0";main(){for(char*c=a; *(short*)c;c+=2){putchar(*(short*)c);}}
g,o,p,i=1e4,a[10001];main(x){for(;p?g=g/x*p+a[p]*i+2*!o: 53^(printf("%.4d",o+g/i),p=i,o=g%i);a[p--]=g%x)x=p*2-1;}The next isn't pi, but e. It is 84 characters long and calculates e to 992 decimal places:
a[999],x,n;main(N){for(;n||(putchar(48^x), n=998+--N);x+=10*a[--n]+!N)a[n]=x%n,x/=n;}
main(char O){O++&&(((O-291)*O+27788)*O-868020?1:putchar(O++) )&&main(O);}
main(c,h,p){for(c/*__*/=21;c--;puts (""))for(h=c%2?3/*/ \*/:0,p=73;p-= printf("%.*s",p,"\\__/ "+h);h=0);}
int _[16];m(x,i,f,z){for(f=z=-9,i=0;i<16;i++)f=_[i]==x?i:f,z=_[i]?z:i;i =abs(f-z);if((i==1&&f/4==z/4)||i==4)i=_[f],_[f]=_[z],_[z]=i;}main(i,j){ srand(time(0));for(i=0;i<9999;i++)i<15?_[i]=i+1:m(rand()%15+1);for(;;){ for(j=i=0;i<16;j+=_[i]==++i)printf(_[i]?"%c%2d":"%c ",i%4?' ':'\n',_[i ]);if(j>14&&puts("\n\nYou WIN"))break;printf("\n\nMove ? ");scanf("%d", &i)||scanf("%*[^0-9]");m(i);}} /* http://alas.matf.bg.ac.yu/~chupcko */
/* chupcko - matf.bg.ac.yu */int _[25];c(h,p){h>0&&h<6&&p>0&&p<6&&(_ [5*p+h-6]^=1);}main(h,p){for(;;){printf(" 1 2 3 4 5");for(h=p=0;h<25; p+=_[h++]){h%5||printf("\n%d",h/5+1);printf(_[h]?" *":" .");}if(p>24&& puts("\n\nYou WIN"))break;printf("\n\nMove ? ");scanf("%d",&p)||scanf( "%*[^0-9]");h=p/10;p%=10;c(h-1,p);c(h,p);c(h+1,p);c(h,p-1);c(h,p+1);}}
main(c,h,p){p=15e4;while((c=getchar())>0){for(h=0;h<29&&h["ETINAMSDRG" "UKWOHBLZFCP\0VX\0Q\0YJ"]!=(c&223);h++);if(h<29)for(h+=2;h>1;h/=2){c=h &1;puts(c++?"\033[11;225]\a":"\033[11;75]\a");usleep(p*c);}else usleep (p*2);usleep(p*2);}} /* echo CHUPCKO morse | ./a.out > /dev/console */
int _[32];main(c,h,p){*_=1;for(c=32;c--;){for(h=c;h /***********/ --;)printf(" ");for(h=0;h<32-c;)printf(_[h++]?"/\\" /* CHUPCKO */ :" ");puts("");for(p=h=1;h<32;p^=_[h++])_[h]^=p;}} /***********/
int _[33]={1};main(c,h,p){for(c=32;h=c--;puts("")){for(;--h;)printf(" ") ;for(p=h=1;h<33-c;p^=h++[_])printf(p?"/\\":" ",h[_]^=p);}}/* CHUPCKO */
int _[32]={1};main(c,h,p){for(c=32;c--;puts(""))for(printf("%*s",c,""),p= h=0;32-c-h;printf(h++[_]?c%2?"/\\":h%2?"/_":"_\\":" "))h[_]^=p,p^=h[_];}
#define m(x,y,z) main(){x##puts(y);##z} #define p m(char c[80];if(gets(c)){main();,c,}) p #define p m(,"Hello world!",) #define m(x,y,z) main(){x##puts(y);##z}
Barcode generating signature:
int/* ./a.out 4008155013759 | xv - */c,h,p;x(y){for(c^=1;1+y--;putchar(p <6?1:c));}y(z){for(p^=63;z--;x(0));p^=63;}main(int/* EAN13 by CHUPCKO */ i,char*_[]){char*z="\220TE0\t\30\3!\22\201\0$,\34\62&\16*\32\26";for(p=4 *printf("P5 95 44 1\n");p--;y(3))for(c=1,y(3),i=1;i<13;i++)for(i==7&&y(5 ),h=0;h<8;h+=2)x(z[i[1[_]]-48]>>((i<7&&z[*1[_]-38]&1<<i-1)?h:(6-h))&3);}
Another Sierpinski triangle:
#define d 500 /* ./a.out > a.pgm; file a.pgm; xv a.pgm; : /\ CHUPCKO */ int _[6+d*d]={d-9,9,d-9,d-9,9,d/2};main(x,y,i,n){for(x=/*/__\*/y=i=0;++ i<3e4;_[6+x*d+y]=1)x+=_[n=rand()%3*2],x/=2,y+=_[n+1],y/*/\ /\*//=2;for (printf("P5 %d %d 1\n",d,d),i=5;i<5+d*d;putchar(!_[++/*/__\/__\*/i]));}
#include <stdio.h> int main(){printf("%d\n",(int)(90-(-4.5//**/ -4.5))); return 0;} /* ais523@?????????? */