number. Write it in binary and number its bits from right to left starting at zero: the lowest bit is position 0, the next one is position 1, and so on.
Return a list of two numbers: how many ones sit at even positions and how many sit at odd positions.number=21 → [3, 0]
21 in binary is 10101. Its ones sit at positions 0, 2 and 4, all even, and there are none at odd positions.
number=12 → [1, 1]
12 is 1100: ones at positions 2 and 3, one even and one odd.
number=1 → [1, 0]
number=21
[3, 0]
Run checks the first 3 tests in your browser. Submit checks all 56 tests on the server, hidden ones included.