Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by tanukiudon
import re
def checkio(line):
vow = ['A', 'E', 'I', 'O', 'U', 'Y']
line = re.sub(r'[.,]+', ' ', re.sub(r'[0-9]+', '11', line)).upper()
line = re.sub(r'[A-Z]', '0', re.sub(r'[AEIOUY]', '1', line)).split()
return len([x for x in line if len(x) > 1 and x.find('00') == -1 and x.find('11') == -1])
#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"
March 2, 2017