← back to unit
Challenge
# queues advanced
The Josephus Rescue
You KNOW the counting game is rigged — every k-th player is out until one survives. You just don't know where to STAND. 🧠
You get the circle size n (players numbered 1..n, counting starts at player 1) and the count k. Simulate the game and print the number of the surviving position.
Example:
Input: n = 7, k = 3
Output: 4
Counting off by 3 around the circle of 7, eliminating every third player, leaves player 4 standing at the end.
💡 need a hint?
q-josephus-rescue.py🔒 given lines are locked — write your code in between
loading...