Code quizz

Started by Bob, January 31, 2007, 01:05:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bob

Here is a little something for those of you that fancy some cool coding:
int magic(int i) {
               int j = 1337, k = 0;
               do k -= i += (i<0 ? 1 : 0) + i;
               while ((j *= 42) != 0);
               return k;
       }
What does the function magic do?

You will for sure know when you find the right answer, so please don't post it here and ruin the fun for somebody else :)
I will later today, or some other day, post some hints if you have problems with it (or you could send me a PM if you're impatient), and finally the solution as well I guess.

Good luck :flirty:
[imga=right]http://77.108.135.49/fahtags/ms10.jpg[/imga]* Threbrilith the Nightelf, born and raised by the Silver Oak Guardians *
Proud member of Dead Men Walking

Jamoe

#1
crash my laptop is what it did lol

doesn't really like php hehe

Bob

Haha :lmfao:

Try using a real programming language Jamoe, like Java or C :narnar:
[imga=right]http://77.108.135.49/fahtags/ms10.jpg[/imga]* Threbrilith the Nightelf, born and raised by the Silver Oak Guardians *
Proud member of Dead Men Walking

Jamoe

#3
hehe, I did convert it to php befor running it lol :flirty:

anyway, as I can't set apache to not ever time out and php runs out of numbers after 10 seconds I guess thats a clue. lol

Anyway, I cans see what its doing, just can't see the point lol.

Anonymous

Quote from: Bob;175349Haha :lmfao:

Try using a real programming language Jamoe, like Java or C :narnar:


what's wrong with Fortran?

Bob

Quote from: BlueBall;175353what's wrong with Fortran?
Nothing at all, but I couldn't list all the "real" programming languages I know about, just took the first two that came to mind :)

Of course I could also have mentioned Fortran, Cobol, Pascal, Prolog, Lisp, Python, Assembly etc, but I didn't see the point :rolleyes:
[imga=right]http://77.108.135.49/fahtags/ms10.jpg[/imga]* Threbrilith the Nightelf, born and raised by the Silver Oak Guardians *
Proud member of Dead Men Walking

Bob

Quote from: Jamoe;175351Anyway, I cans see what its doing, just can't see the point lol.
Seriously, can you really see what it's doing, just by looking at the code :blink:

Either you're exceptionally bright, or you don't see what it actually does (meaning, what the "general" result of the function is) :g:
[imga=right]http://77.108.135.49/fahtags/ms10.jpg[/imga]* Threbrilith the Nightelf, born and raised by the Silver Oak Guardians *
Proud member of Dead Men Walking

Jamoe

ADA, Eiffel, C# nice

Prolog = Evil

Gandalf

You need to run it to work that out?

For shame. Easy, NEXT.
*G*

Cake: Four large eggs. One cup semi-sweet chocolate chips. Three/four cups butter or margarine. One and two third cups granulated sugar. Two cups all purpose flour. Fish shaped ethyl benzene. Twelve medium geosynthetic membranes. Three tablespoons rhubarb, on fire.

Jamoe

Quote from: Bob;175356Seriously, can you really see what it's doing, just by looking at the code :blink:

Either you're exceptionally bright, or you don't see what it actually does (meaning, what the "general" result of the function is) :g:

the result of the function? u mean it actually has one?

Bob

Quote from: Jamoe;175359the result of the function? u mean it actually has one?
Yes indeed :rolleyes:
And a quite sensible result as well...
And the whole point for you is to figure out what (which Gandy obviously thinks is quite easy :blink:)...
[imga=right]http://77.108.135.49/fahtags/ms10.jpg[/imga]* Threbrilith the Nightelf, born and raised by the Silver Oak Guardians *
Proud member of Dead Men Walking

Jamoe

lol so much for php, weakly typed languages ftl

Gandalf

I may have it wrong, but.... PM'ed
*G*

Cake: Four large eggs. One cup semi-sweet chocolate chips. Three/four cups butter or margarine. One and two third cups granulated sugar. Two cups all purpose flour. Fish shaped ethyl benzene. Twelve medium geosynthetic membranes. Three tablespoons rhubarb, on fire.

Jamoe

yea, i had forgotten that php will automaticaly convert ints to floats when they go over certain sizes.

thanks to Bob for the int tip, it finally makes sense. lol

Gandalf

*G*

Cake: Four large eggs. One cup semi-sweet chocolate chips. Three/four cups butter or margarine. One and two third cups granulated sugar. Two cups all purpose flour. Fish shaped ethyl benzene. Twelve medium geosynthetic membranes. Three tablespoons rhubarb, on fire.