Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by khoa.nguyen.9822924
# migrated from python 2.7
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
temp = ''
for i in text.upper():
if i in VOWELS:
temp += 'A'
elif i in CONSONANTS:
temp += 'B'
elif i.isdigit():
temp += i
else:
temp+= '|'
sum = 0
for i in temp.split('|'):
if len(i) > 1 and not [str for str in i if str.isdigit()] :
if not ( i.count('AA') or i.count('BB') ):
sum += 1
return sum
#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"
Sept. 19, 2014