Ctrl K

Never Caught the Ball

Easy
players kids sit in a circle, in seats numbered 1 to players clockwise; after seat players comes seat 1 again. The kid in seat 1 holds the ball first and throws it step seats clockwise. Whoever catches it throws it 2·step seats on, the next one 3·step seats, and so on: every new throw goes step seats farther than the last. The game stops as soon as someone gets the ball for the second time. Return, in increasing order, the seat numbers of the kids who never held the ball.
Example 1
players=6, step=2 → [2, 4, 5, 6]

Player 1 starts. A throw of 2 seats reaches player 3, a throw of 4 seats brings it back to player 1, who now holds it a second time, so the game ends. Players 2, 4, 5 and 6 never held the ball.

Example 2
players=3, step=1 → [3]

1 → 2 (one seat) → 1 (two seats). Player 3 never got the ball.

Example 3
players=8, step=3 → []
Constraints
  • 1 ≤ step ≤ players ≤ 50
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsNoughts and Crosses Verdict EasyEnd of the Doubling Chain EasyClearing the Stacks Evenly EasyRemainder-One Whiteboard EasyMirrored Codes Easy
loading Python…
Input
players=6, step=2
Expected
[2, 4, 5, 6]

Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.