players players stand in a row, numbered from 1 to players. At the start, player 1 holds the potato. Every second, whoever holds it passes it to the next player along the row. When it reaches the last player it turns around and travels back; at the first player it turns around again, and so on.
Return the number of the player holding the potato after seconds seconds.players=3, seconds=6 → 3
The potato goes 1 → 2 → 3 → 2 → 1 → 2 → 3, so after 6 seconds player 3 has it.
players=5, seconds=2 → 3
1 → 2 → 3: the potato has not reached the end of the row yet.
players=4, seconds=7 → 2
players=3, seconds=6
3
Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.