moves lists its moves in order: a positive number means it travels that many metres to the right, a negative one means it travels the absolute value to the left.
After each move we look at where the cart has stopped. Return how many times it stopped exactly at the dock.
Passing the dock in the middle of a move does not count; only the stopping point matters. The starting position does not count either.moves=[4, -1, -3, 2, -2] → 2
Positions after each move: 4, 3, 0, 2, 0. The cart stops at the dock twice.
moves=[3, -5, 4] → 0
Positions: 3, −2, 2. During the second move the cart rolls past the dock without stopping there, which does not count.
moves=[4, -1, -3, 2, -2]
2
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.