Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Striped Words by mdroz
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
text = text.replace(","," ")
text = text.replace("."," ")
text = text.replace("?"," ")
wds = text.split()
count = 0
for w in wds:
i=0
while i < len(w)-1:
if len(w) > 1:
if VOWELS.count(w[i].upper()) == 0 and CONSONANTS.count(w[i].upper()) ==0:
i = len(w)-1
elif VOWELS.count(w[i].upper()) == VOWELS.count(w[i+1].upper()):
i = len(w)-1
elif CONSONANTS.count(w[i].upper()) == CONSONANTS.count(w[i+1].upper()):
i = len(w)-1
i+=1
if i == len(w)-1:
count+=1
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"
Oct. 24, 2017
Comments: