← Back to challenges

Count the Lone Ones

PythonHardalgorithmsloopsnumbersregex

Instructions

Create a function which counts how many lone 1s appear in a given number. Lone means the number doesn't appear twice or more in a row.

Examples

count_lone_ones(101) ➞ 2

count_lone_ones(1191) ➞ 1

count_lone_ones(1111) ➞ 0

count_lone_ones(462) ➞ 0

Notes

Tests will include positive whole numbers only.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.