bits with no leading zeros.
Repeat one action until the number equals 1:
- if the number is even, divide it by 2;
- if it is odd, add 1 to it.
Return how many actions this takes. Note that the string can be hundreds of characters long.bits="1011" → 6
This is 11: 11 → 12 → 6 → 3 → 4 → 2 → 1, which takes 6 steps.
bits="100" → 2
This is 4: two halvings, 4 → 2 → 1.
bits="1" → 0
bits consists of the characters '0' and '1'bits="1011"
6
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.