Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Striped Words by madmanbob
VOWELS = "AEIOUY"
def isstriped(word):
if len(word) <= 1:
return False
for i in range(len(word) - 1):
if (word[i].upper() in VOWELS) == (word[i + 1].upper() in VOWELS):
return False
return True
def checkio(text):
words = "".join([char if char.isalnum() else " " for char in text]).split(" ")
return len([word for word in words if word.isalpha() and isstriped(word)])
# 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. 8, 2013
Comments: