Posted by flashman on Mon May 17th at 11:19pm 2004
Each of you are allocated a number and ordered to stand in a circle - in sequence.
Starting at no.1 and moving clockwise, the executioner shoots every other man in turn until only one is left - he is reprieved.
If you could choose your number, what would it be?
What if there were thirty-seven prisoners?
Or ninety-three?
What if there were X no.
A tenner to the Charity designated by the person who posts the briefest correct answer to the last.
Posted by 7dk2h4md720ih on Mon May 17th at 11:23pm 2004
Posted by Leperous on Mon May 17th at 11:24pm 2004
Leperous
member
3382 posts
788 snarkmarks
Registered: Aug 21st 2001
Location: UK
Occupation: Lazy student
Posted by Kage_Prototype on Mon May 17th at 11:32pm 2004
Kage_Prototype
member
1248 posts
165 snarkmarks
Registered: Dec 10th 2003
Location: Manchester UK

Occupation: Student
Posted by mazemaster on Mon May 17th at 11:35pm 2004
Posted by Leperous on Mon May 17th at 11:39pm 2004
Ok, so you want to be x-1'th if there's an odd number of people, and x'th if there are an even number of people.
Leperous
member
3382 posts
788 snarkmarks
Registered: Aug 21st 2001
Location: UK
Occupation: Lazy student
Posted by 7dk2h4md720ih on Mon May 17th at 11:45pm 2004
Posted by flashman on Mon May 17th at 11:48pm 2004
1 x 3 x 5 x 7 x 9 x 11 x 2 x 6 x 10 x 4 x 12 - leaving 8
Shoot one-miss one-shoot one-miss one...
Posted by fraggard on Tue May 18th at 3:58am 2004
| ? posted by flashman |
| What if there were thirty-seven prisoners? Or ninety-three? |
This is the classic Josephus problem, isn't it? There's a formula I used to use for this one... I think it is:
Survivors position = 1 + 2X - 2^floor(1+lg(X))
lg(X) is to the base 2.
For 37, it's 11. For 93, it's 123. (Edit: Should be 58. I'm stupid)
fraggard
member
1110 posts
201 snarkmarks
Registered: Jul 8th 2002
Location: Bangalore, India

Occupation: Student
Posted by flashman on Tue May 18th at 8:41am 2004
Survivors position = 1 + 2X - 2^floor(1+lg(X))
lg(X) is to the base 2.
For 37, it's 11. For 93, it's 123.
The answer is always an even number - All odd numbers are taken out in the first circuit.
Posted by Leperous on Tue May 18th at 9:08am 2004
Ok, so 2n - 2^floor(1+log2(n)) for n>2 then ![]()
Leperous
member
3382 posts
788 snarkmarks
Registered: Aug 21st 2001
Location: UK
Occupation: Lazy student
Posted by fraggard on Tue May 18th at 11:24am 2004
| ? posted by Leperous |
|
Ok, so 2n - 2^floor(1+log2(n)) for n>2 then |
What he said.
And the number for 93 is wrong... It should be 58. (59 by the forumla, 58 for your answer)
fraggard
member
1110 posts
201 snarkmarks
Registered: Jul 8th 2002
Location: Bangalore, India

Occupation: Student
Posted by mazemaster on Tue May 18th at 11:56am 2004
1....1
2....2
3....2
4....4
5....2
6....4
7....6
8....8
9....2
10...4
11...6
12...8
13...10
14...12
15...14
16...16
17...2
18...4
[...]
31...30
32...32
33...2
[...]
64...64
65...2
[...]
128..128
Posted by fraggard on Tue May 18th at 3:24pm 2004
I was looking around, and found another solution...
Apparently, if you convert X to binary, and then rotate all the bits left by 1 place, you get the final position to be in.
If X = X1X2X3X4X5...Xn-1Xn In binary, then Rotating it to become X2X3X4...XnX1 gives you the final position. (For this particular case, you have to subtract 1 from that value, I think.)
fraggard
member
1110 posts
201 snarkmarks
Registered: Jul 8th 2002
Location: Bangalore, India

Occupation: Student
Snarkpit v6.1.0 created this page in 0.0113 seconds.

