+ 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?
5 Antworten
+ 3
My answer to this is here...
https://code.sololearn.com/c5H5ruc9Utec/?ref=app
+ 3
@Andrew G because it teased my brain while making the code.
+ 2
now solve it for n people...
not that hard btw
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
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.