0

how can we code the josephus qustion?

please give me some tips! thank you!

24th Nov 2017, 8:09 AM
true_
true_ - avatar
1 Resposta
+ 1
By which, I assume you are referring to the question where people stand in a circle slaying each other until one is left. Such a diabolical question. *Sighs* Have an array [1, 1, 1...] indicating the number of people and their condition. (Basically 1 means their alive and 0 means they're dead.) Go through the loop, checking if the current element is 1. If so, set the next 1 in the array to 0. Repeat until only one 1 is left. Hope this helped! 😉 (Unless you're talking about a different question.)
24th Nov 2017, 11:34 AM
blackcat1111
blackcat1111 - avatar