ring, so the first player comes right after the last. The host calls out a number span, and everyone rewrites their card at the same moment:
- if span > 0, a player writes the sum of the numbers held by the next span players clockwise;
- if span < 0, the sum of the |span| players before them;
- if span = 0, they write 0.
Everyone works from the old numbers. Return the new numbers in the same order.ring=[3, 1, 4, 2], span=2 → [5, 6, 5, 4]
Each number becomes the sum of the next two around the circle: [1+4, 4+2, 2+3, 3+1] = [5, 6, 5, 4].
ring=[3, 1, 4, 2], span=-1 → [2, 3, 1, 4]
Each number takes the one before it; for the first element, that is the last one.
ring=[6, 9], span=0 → [0, 0]
With span = 0 every number turns into 0.
ring=[3, 1, 4, 2], span=2
[5, 6, 5, 4]
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.