1 means the switch is on and a 0 means it is off (the rightmost bit is the first switch). The row is as long as needed, so leading zeros are switches that are off.
One action toggles exactly one switch. Given the current state current and the desired state target, return the minimum number of toggles that turns current into target.current=12, target=5 → 2
12 is 1100 and 5 is 0101. They differ in the first and the fourth bits from the right, so 2 toggles are needed.
current=0, target=7 → 3
7 is 111, so three switches have to be turned on.
current=9, target=9 → 0
current=12, target=5
2
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.