What does it do?

Stump your fellow simians.
User avatar
Witness
Posts: 16428
Joined: Thu Sep 19, 2013 5:50 pm
Has thanked: 1988 times
Been thanked: 2718 times

What does it do?

Post by Witness » Tue Aug 25, 2015 3:28 am

Found this small program in a book:

Code: Select all

int a=10000,b,c=8400,d,e,f[8401],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);}

User avatar
Doctor X
Posts: 67488
Joined: Fri Jun 04, 2004 8:09 pm
Title: Collective Messiah
Location: Your Mom
Has thanked: 3374 times
Been thanked: 2144 times

Re: What does it do?

Post by Doctor X » Tue Aug 25, 2015 7:39 am

Simple:
Image
Your stereo is mine, of course. . . .

--J.D.
Mob of the Mean: Free beanie, cattle-prod and Charley Fan Club!
"Doctor X is just treating you the way he treats everyone--as subhuman crap too dumb to breathe in after you breathe out."--Don
DocX: FTW.--sparks
"Doctor X wins again."--Pyrrho
"Never sorry to make a racist Fucktard cry."--His Humble MagNIfIcence
"It was the criticisms of Doc X, actually, that let me see more clearly how far the hypocrisy had gone."--clarsct
"I'd leave it up to Doctor X who has been a benevolent tyrant so far."--Grammatron
"Indeed you are a river to your people.
Shit. That's going to end up in your sig."--Pyrrho
"Try a twelve step program and accept Doctor X as your High Power."--asthmatic camel
"just like Doc X said." --gnome

WS CHAMPIONS X3!!! NBA CHAMPIONS!! Stanley Cup! SB CHAMPIONS X5!!!!!
AL East Champs!!

User avatar
Rob Lister
Posts: 19827
Joined: Sun Jul 18, 2004 7:15 pm
Title: Incipient toppler
Location: Swimming in Lake Ed
Has thanked: 570 times
Been thanked: 579 times

Re: What does it do?

Post by Rob Lister » Tue Aug 25, 2015 9:45 am

Witness wrote:Found this small program in a book:

Code: Select all

int a=10000,b,c=8400,d,e,f[8401],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);}
Spoiler:
Pi, sloppily.

Code: Select all

main(){
        int a=10000,b,c=8400,d,e,f[8401],g;
        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);
      }
Never test cheaters.

User avatar
DrMatt
BANNED
Posts: 29811
Joined: Fri Jul 16, 2004 4:00 pm
Location: Location: Location!
Has thanked: 143 times
Been thanked: 70 times

Re: What does it do?

Post by DrMatt » Tue Aug 25, 2015 3:33 pm

Obscure code is no longer impressive.
We've all heard the story of Mel.
Grayman wrote:If masturbation led to homosexuality you'd think by now I'd at least have better fashion sense.

User avatar
Witness
Posts: 16428
Joined: Thu Sep 19, 2013 5:50 pm
Has thanked: 1988 times
Been thanked: 2718 times

Re: What does it do?

Post by Witness » Wed Aug 26, 2015 11:48 pm

Well done Rob, you nailed it.

@ Matt: read the Mel story with pleasure, reminded me of a time when bits were set with switches. But I think the programmer diden't want to obfuscate (which I used, of course), just to show that lots of π's decimals could be generated with a handful of bytes.