presses describes one press: if the number's binary form has a 1 in bit b, the press flips switch b (on ↔ off). Bit 0 is the least significant.
Take a contiguous segment of presses and run it on a panel with every switch off. The segment is a *reset* if the panel ends up fully off again.
Return how many reset segments presses contains.presses=[5, 3, 6, 1] → 1
5 = 101₂, 3 = 011₂, 6 = 110₂. The presses [5, 3, 6] flip every switch exactly twice, so the panel is dark again. No other segment does that.
presses=[0, 4, 4] → 3
[0], [4, 4] and [0, 4, 4] qualify.
presses=[1, 2, 4] → 0
presses=[5, 3, 6, 1]
1
Run checks the first 3 tests in your browser. Submit checks all 119 tests on the server, hidden ones included.