+ 3

What would be your code to solve Josephus Problem? It's an interesting one...

100 people are standing in a circle. The first person has a knife. He kills the next person (2nd person) and gives the knife to the next alive (3rd person). This continues... Who would survive?

20th Nov 2017, 6:26 PM
Aditya Rana
8 Respostas
+ 3
20th Nov 2017, 6:26 PM
Aditya Rana
+ 3
@Andrew G because it teased my brain while making the code.
25th Nov 2017, 3:02 AM
Aditya Rana
+ 2
now solve it for n people... not that hard btw
21st Nov 2017, 1:33 PM
Illusive Man
Illusive Man - avatar
0
My solution is based on a mathematical approach. There's no container of indices in my code. https://code.sololearn.com/cSt4G6jW1HMn/?ref=app
28th Nov 2017, 1:59 PM
Timon Paßlick
0
https://code.sololearn.com/c1lMnXrfm7sD/#py my solution Tried to do without condition. With a loop to kill n-1 people -- only one will remain.
23rd Mar 2018, 8:05 PM
Attila