Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First - check for disjoint and intersected sets solution in Clear category for Striped Words by leggewie
from re import split
def is_striped(word: str) -> bool:
'''
check if word is a striped word (strictly alternating vowel and consonants)
'''
if len(word) <= 1 or set(word).intersection("0123456789"):
return False
v = "aeiouy" # vowels
c = "bcdfghjklmnpqrstvwxz" # consonants
el = set(word[::2].lower()) # even letters
ol = set(word[1::2].lower()) # odd_letters
return el.isdisjoint(v) and ol.isdisjoint(c) or ol.isdisjoint(v) and el.isdisjoint(c)
def checkio(line: str) -> int:
counter = 0
for word in split("[,\ .]",line.lower()):
counter += is_striped(word) # treating True as 1 here
return counter
June 1, 2021
Comments: