Long time no see!
I know this is an old topic, but I felt it's better to post this here, instead of starting a new one. I've made another program, similar to the other ones in that the whole program body is in one 'return' statement. However, this one is actually interactive.
IMPORTANT: This won't work on Windows. See below.
Code: Select all
#define _ main
#include <stdio.h>
#define clrscr() printf("\e[H\e[2J")
int _(int t,int p,int a){return-1==t?p+_(-9,_(-3,p,-2),0)==a?0:_(t,_(-10,p,t),a
):t==-16?p>95?p-71:p>60?p-65:p<44?p+19:p>47?p+4:p+16:t==35018?60:t>=0?t<34640?_
(-1,4128831,0):t%40==38?32:t==35019?62:t%40==39?10:_(-10-4,p+t/2%20-9+(t/40-866
-9<<16),a)?32:35:t==-10?_(t-1,getchar(),p):t==-3?_(-9,clrscr(),0)?a:_(a,p,34640
):t==-13?_(t-1,p+a,a)?p+a:p:t==-11?_(t-1,a,p>92?p-109:p-77):t==-2?a>=35400?0:_(
-9,putchar(_(a,p,a)),0)?p:_(t,p,a+1):t==-15?_(t-1,_(t*2,a,p/6),a)&_(p%6-9,2,1):
t>-9?_(t-1,p,a*p):t==-14?p>>16<0||p>>16>=64||(p&65535)>=64?0:_(t-1,(p&65535)+(p
>>16)*64,a):t==-9?a:t==-12?_(t-1,p,a==10?-65536:a==-9?1:a==-12?-1:a==6?65536:0)
:"1/Xj37/92vbXAvNnCy5GtX1HyNa/qZ+WXV+l+l028oeT1i9y764wzWXXPwhzZ5F1TGexzH35L9Zn\
O0mpeSrclX++mypwWcJLeV6uR73uxf7aua1Xh2mTqW72VL2r2ubvvSzuemqqkTcqtzcs46uX3t1l1V\
NVZUd02rPr19+176GrWuzjaVlabjWNGT/sdrdrcXeXW4sg2YvVeN+8p9d3FOuq+ywWitmv1afR3Vtr\
WNeXdtdr3ma9da+o2NnG7VQVq6f1abj19b/qB1qrt1moK2z32pO2r+57VVzUzUr20Fb7i2t1XL3wev\
4ZnWnsOb5q60FaLrNO9R/5W/jOvd+SPpJlKtusNYW+vvb8d62+dVYWqFh5VF0c9d7W73V372a1q1uJ\
xEqrmq5Dr09r/Vbvurv8zqCRPtsKD6qbsvV9tyevYItFtphtbt6l7WftrXmzaRPbt4uKtAn9tcatUs\
2au2Vd1za/qq94p70m2dk6W15NyZsk5tUN129l86tya1arrV9olqwVrquVblmubXt6bkXSffmdauK7\
v4Ohsu476dZYj21u8qYR53tO2bp525ZprtcrzrV3y7brxVrjKO6CJnXmbH3y6x/uL8Wbe13qnoq8wW\
7QVmWt2e5bNz3efbd1dh1aXbMgb1143rapd8Vbo7TK7lj9ybdCU/eTvP6r79P"[a];}
To run this program, compile it and type:
Code: Select all
stty -icanon; ./programname; stty cooked
Then find the upper-left corner. Use WASD, not arrows.
(In "-icanon mode", getchar() doesn't wait for the Return key, and returns the code immediately after a character was typed.)
This version only works on Linux tty's. To port it to Windows, one should #include <conio.h>, replace getchar() with getch(), and re-implement clrscr(), probably with system("cls"), but that might be slow and I didn't test it. (Maybe printf("\n\n\n\n\n\n\n\n...\n\n\n") would work as well, by scrolling the old screen content, thus "clearing" it.)
(The standard DOS conio.h already has clrscr, so one could simply remove the #define clrscr. But the one shipped with MinGW doesn't.)