Page 1 of 1

One little program

Posted: Fri Dec 02, 2005 2:47 pm
by Tomi
I know this isn't related to RnD, so it should belong to Off Topic, but there's no "Off Topic Programmer's Corner" :) and I think Programmer's Corner suits this better than Off Topic. Well, this is it - my newest piece of programming art:

Code: Select all

#include <stdio.h>
{return b==982?main(127,a<79?main(a+1,982):128):a==51?72:a>
gcc -o nameless.exe nameless.c
No malicious code included (it uses just putchar). You may get some warnings however (implied type of a,b etc.) Try to guess what it does. :wink:

Posted: Fri Dec 02, 2005 5:07 pm
by Holger
Very nice! :-)

Also try this one:

Code: Select all

float s=1944,x[5],y[5],z[5],r[5],j,h,a,b,d,e;int i=33,c,l,f=1;int g(){return f=
(f*6478+1)%65346;}m(){x[i]=g()-l;y[i]=(g()-l)/4;r[i]=g()>>4;}main(){char t[1948
]=" `MYmtw%FFlj%Jqig~%`jqig~Etsqnsj3stb",*p=t+3,*k="3tjlq9TX";l=s*20;while(i<s)
It's not by me, but can be found here:

Posted: Fri Dec 02, 2005 5:39 pm
by Tomi
That one is nice too... however, I had other goal when creating the one above - to make a program which would have just main() with one return, contain no string and be protected against debugging. (Seriously! It contains a *long* idle loop, called several times!)
This one (not by me) is definitely the best though:

Code: Select all

#include <stdio.h>
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
;#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;# \
){nl]!/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' ')# \
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);
I've studied a bit and found some way to get a "On the ,first,second,third,..." data string out of it, but how does it do it remains a mystery. A pity that I don't know who made it.

Posted: Fri Dec 02, 2005 7:02 pm
by Holger
Really cool... :-o

Posted: Sun Dec 11, 2005 12:49 pm
by Zomis
I seriously have no idea what these does, but maybe you can see:
Taken from: ... le1637.asp

Code: Select all

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

Code: Select all

--            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,"_.":" |"];}

Posted: Thu Feb 09, 2006 11:19 pm
by Francesco
Cool! If learning C would mean to manage things like the above, I seriously need to find a rope to hang myself from the ceiling... :wink:

(you don't really need to consider this post, I'm just taking a walk in these Turkish threads... :wink: )

Posted: Fri Feb 10, 2006 8:34 pm
by Holger
Don't worry -- I probably could never write or understand such programs... It would take too much time which I would better like to spend on other things. :-)

But it looks crazy and it's always nice to see that it actually does something! :-)

Posted: Fri Jun 20, 2008 6:25 pm
by Tomi
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
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.)