Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Striped Words by MartynaDziubalka
VOWELS = "AEIOUY"
def checkio(text):
count = 0
words = trim(text).split(" ")
for word in words:
if len(word) < 2 or not word.isalpha():
continue
word_is_correct = True
b = is_vowel(word[0])
for i in range(1, len(word)):
a = is_vowel(word[i])
if not ((a and not b) or (not a and b)):
word_is_correct = False
break
b = a
if word_is_correct:
count += 1
return count
def trim(text):
result = ""
for x in text:
if x.isalnum():
result += x
else:
result += " "
return result
def is_vowel(letter):
return letter.upper() in VOWELS
#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. 29, 2016