|
This month's IEEE GlobalSpec newsletter challenge is:
One hundred people stand in a circle in order, numbered 1 to 100. No. 1 has a sword. He kills the next person (i.e. No. 2) and gives the sword to the next living person (i.e. No. 3). All people do the same until only 1 survives. Which number survives to the end?
Extra credit: How would you set up a solution when the number of participants is in the form 2n? How is this approach unique?
And the answer is:
This is a variant of a classic counting-out puzzle called the Josephus problem.
If we play this game with 2n participants, the number of participants can halve without a remainder. For this reason, the winner will always be No. 1.
With 100 participants, 36 of them will have to die to get down to a power of 2 (64). Since we kill every other person starting at No. 2 the last person to die is No. 72. They will be killed by No. 71 and No. 73 will win.
Therefore, the formula 2 x (X – Y) + 1, where X is the total number of players and Y is the highest power of 2 that is less than or equal to X, solves the problem.
|
Good Answers:
"Almost" Good Answers: