Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Striped = Binary solution in Clear category for Striped Words by thz
from re import split
def checkio(line: str) -> int:
def is_striped(word: str) -> bool:
if len(word) < 2 or not word.isalpha():
return False
vowels = 'AEIOUY'
bins = ''.join(map(lambda ch: '01'[ch in vowels], word.upper()))
return all(['00' not in bins, '11' not in bins])
words = split(r'\W', line)
return sum(map(is_striped, words))
if __name__ == '__main__':
print("Example:")
print(checkio('My name is ...'))
# These "asserts" are used for self-checking and not for an auto-testing
assert checkio('My name is ...') == 3
assert checkio('Hello world') == 0
assert checkio('A quantity of striped words.') == 1
assert checkio('Dog,cat,mouse,bird.Human.') == 3
print("Coding complete? Click 'Check' to earn cool rewards!")
Nov. 20, 2021