Ones and Zeroes

Published by Helen Yu in

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

Watch a quick demo on how Edabit works.