5 XP challenge

Alternate Moves on a Ring

very easy
Build it yourself · 3 min
1 Learn2 Predict3 Solve

Task
Your mission

Starting at position 0, make the number of moves given by turns around a ring containing size positions. Alternate firstMove and secondMove. Return the final position. size is 1 to 20; move sizes are 0 to 20; turns is 0 to 20.

Examples

InputReturn
size = 7, firstMove = 2, secondMove = 3, turns = 3

position: 0 → 2 → 5 → 0. The result is 0.

0
size = 7, firstMove = 2, secondMove = 3, turns = 2

position: 0 → 2 → 5. The result is 5.

5

Your code

Write your answer inside Solution, then use return to send it back.

Try examples runs the public examples. Check my code checks your full answer and saves your completion.