On February 26 2009 08:10 antiq wrote:
May I join in? This is not a riddle per se, but a mathematical problem my bro had to cope with in some obscure programming class.
Say .. Jimmy walks into the classroom and sees a set of numbers on the blackboard:
1,2,3,4,5, .. etc .. N
Now, he is a bit goofy, think Rainman, so he starts to play with the numbers:
He picks a number, say R - then adds together the first R numbers from the set in his head, deletes them and writes their sum at the end of the whole set (after the initial N).
(If there are no more R numbers in the set, he just takes all that are left)
And he decides to do this K-times .. so, what is the last number in the set now (the K-th number which he writes)?
If you have N=5 (that means 1,2,3,4,5); R=2, K=3, it's obvious, you get
1,2,3,4,5
3,4,5,3
5,3,7
7,8 -> so the answer is 8
But say you have a range of numbers 1-1^9 (1-billion) for N,R and K ...
How would you get the answer if the input was N=92312386, R=432765 and K=87397?
Write a computer program that does the whole procedure fast, yes.. but no, not really the hard way you would expect. The thing is, the numbers get too huge even for normal computers - and the limit for this program was set at 64MB used and 1sec time anyway.
Any mathematically gifted among the TL-netters? Btw, I don't know the answer and the number doesn't interest me that much, the interesting thing is the algorithm, how did you get the result (I don't know the algorithm either :3)
May I join in? This is not a riddle per se, but a mathematical problem my bro had to cope with in some obscure programming class.
Say .. Jimmy walks into the classroom and sees a set of numbers on the blackboard:
1,2,3,4,5, .. etc .. N
Now, he is a bit goofy, think Rainman, so he starts to play with the numbers:
He picks a number, say R - then adds together the first R numbers from the set in his head, deletes them and writes their sum at the end of the whole set (after the initial N).
(If there are no more R numbers in the set, he just takes all that are left)
And he decides to do this K-times .. so, what is the last number in the set now (the K-th number which he writes)?
If you have N=5 (that means 1,2,3,4,5); R=2, K=3, it's obvious, you get
7,8 -> so the answer is 8
But say you have a range of numbers 1-1^9 (1-billion) for N,R and K ...
How would you get the answer if the input was N=92312386, R=432765 and K=87397?
Write a computer program that does the whole procedure fast, yes.. but no, not really the hard way you would expect. The thing is, the numbers get too huge even for normal computers - and the limit for this program was set at 64MB used and 1sec time anyway.
Any mathematically gifted among the TL-netters? Btw, I don't know the answer and the number doesn't interest me that much, the interesting thing is the algorithm, how did you get the result (I don't know the algorithm either :3)
I believe Sean Plott (Day[9]) is a math man.