100 Soldiers are standing in a circle in the order from 1 to 100. Soldier number 1 has a sword. He kills soldier number 2 and gives the sword to soldier number 3. All the soldiers do the same until only 1 survives. Which soldier (number) will survive in the end?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Solution too bookish it can be done logically without pen and paper
1 0 0 1 0 0 1 0 0 = 2 a + k a is the highest power = 6 4 + 3 6 = 2 6 + 3 6
The ( 2 k + 1 ) th person will survive ⟹ 2 ( 3 6 ) + 1 ⟹ 7 3
The problem is known as Josephus problem. Watch this excellent video by Numberphile here
Can you please elaborate a little please?
Log in to reply
I have shared a great YouTube video. The video can explain better than I can, so best you watch that. If you have any doubts, I'll surely help if I can.
Sooooo hard.
im only a 8 yr old. holy cow.
Log in to reply
It's alright! Have fun looking through my Brilliant page with other interesting problems :)
where IS your brilliant page?
Log in to reply
Click my name, it takes you to where I posted all my math problems.
Check out numberphiles on YouTube. The video titled “The Josephus Problem” explains this exact problem in great detail.
Ok. Thanks!
The problem is well discussed in "Concrete Mathematics by Graham, Knuth and Patashnik"
The simplest solution is:
First step: Binary representation of 100. That is 100=1100100
Solution: Cyclic left shift one bit 1001001=73
Does this work everytime ?
Let S i be the set of survivors after the sword has made i circuits.
First circuit: the even numbers are killed, leaving all the odds for the second circuit. S 1 = { n : n ≡ 1 m o d 2 }
Second circuit: every n congruent to 1 m o d 4 kills the number two higher. S 2 = { n : n ≡ 1 m o d 4 }
Third circuit: every n kills the number 4 higher. S 3 = { n : n ≡ 1 m o d 8 } . Note, however, that S 3 has an odd number of elements, so our #1 guy is doomed
Fourth circuit: every n starting with 9 kills the number 8 higher. S 4 = { n : n ≡ 9 m o d 1 6 } We're down to 6 numbers left.
Fifth circuit: we keep the first, third, and fifth elements of previous set. S 5 = { n : n ≡ 9 m o d 3 2 } = { 9 , 4 1 , 7 3 }
Sixth circuit: 9 kills 4 1 and hands sword to 7 3 . S 6 = { n : n ≡ 9 m o d 6 4 } = { 9 , 7 3 }
Seventh circuit: 7 3 kills 9 and is the sole survivor.
As a newbie to math, I understand the logic (the same train of thought I had used to approach the problem), but don’t understand the math symbols you use, so cannot reproduce it. My fault. Still, thank you for this one!
The solution requires getting the nearest smaller number that is the power of 2, in this case 64 and subtract it with the given number.100-64=36. Now we apply the formula; 2n+1 = 2*36 + 1 = 72 + 1 = 73. Hence answer = 73
Why does this work?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Use Euclid's division lemma
First remove 2n
Then remove 4n +3
Then keep cutting until u reach the ans 73
This programme should be able to give us the solution for any number of soldiers, Am I wrong??
list = []
for x in range(soldiers):
list.append(x+1)
i = 1
while len(list) > 1:
prev = int(list[-1])
del list[i::2]
next = int(list[-1])
#In case the cycle ended with the last soldier dead, the first soldier won't be killed, otherwise, it will.
if next == prev:
i = 0
else:
i = 1
print(list)
In every chanceor round alternate guy been killed so it makes an Arithmetic progression
1+2( n-1) This shows where the sword goes, in the last sword goes to 99 and he killed 100 and give sword to 1
1+4(n-1) This shows where the sword goes, the last sword goes to no.97 and he killed 99 and gave sword to 1
1+8( n-1) This shows where the sword goes, in last the sword goes to no. 97 and killed 1 and gave sword to 9 Now the sword goes to 9+16( n-1) if we put n= 5 we get the ans. 73
Problem Loading...
Note Loading...
Set Loading...
Let J ( n ) be the number of the surviving soldier when there are n soldiers in the ring. Of course, J ( 1 ) = 1 .
Now that we have these recurrence relations, we can prove the following by induction:
Proof : If n = 1 then a = k = 0 , so 2 k + 1 = 1 = J ( 1 ) . Suppose inductively that N > 1 and the the above formula works for all numbers smaller than N .
Since 1 0 0 = 2 6 + 3 6 , the answer is 7 3 .