← Back to challenges

Ones and Zeroes

PythonHardstringsloopsregexvalidation

Instructions

Write a function that returns True if every consecutive sequence of ones is followed by a consecutive sequence of zeroes of the same length.

Examples

same_length("110011100010") ➞ True

same_length("101010110") ➞ False

same_length("111100001100") ➞ True

same_length("111") ➞ False

Notes

N/A

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