Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by hypehr96
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
DIGIT = "0123456789"
def checkio(text):
text = text.upper()
text+=" "
last = 0
k=0
d=0
count=0
wait=0
for i in text:
if i in VOWELS and last!='V' and wait!=1:
d+=1
last='V'
k+=1
elif i in CONSONANTS and last!='C' and wait!=1:
d+=1
last='C'
k+=1
elif i in VOWELS or i in CONSONANTS or i in DIGIT:
wait=1
k+=1
else:
print(str(d)+"-"+str(k))
if k==d and k>1:
count+=1
k=0
d=0
last=0
wait=0
return count
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("My name is ...") == 3, "All words are striped"
assert checkio("Hello world") == 0, "No one"
assert checkio("A quantity of striped words.") == 1, "Only of"
assert checkio("Dog,cat,mouse,bird.Human.") == 3, "Dog, cat and human"
Jan. 9, 2017