#1 Tiny coding teaser
Posted: Tue Oct 30, 2007 11:00 am
int f(int x) { (x!=0) ? (return X&1+f(x>>1)) : (return 0) }
int main
{
int a=?
f(x );
}
Part 1:
What does int f(x) do?
Part 2: Using the following stack trace, can you conclusively tell if a was a number greater then 30?
EDIT: I fucked up the stack trace, that should be 12, nor 16. I screwed up my math and i'm too tired to fix the image
Note: The left side is adresses randomly chosen, as is the longer hex data fragment on the right.
This contains all the data you need.
Oh, right, the data fragment is in hex, answer me in decimal.
int main
{
int a=?
f(x );
}
Part 1:
What does int f(x) do?
Part 2: Using the following stack trace, can you conclusively tell if a was a number greater then 30?
EDIT: I fucked up the stack trace, that should be 12, nor 16. I screwed up my math and i'm too tired to fix the image
Note: The left side is adresses randomly chosen, as is the longer hex data fragment on the right.
This contains all the data you need.
Oh, right, the data fragment is in hex, answer me in decimal.