Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by bocian.michal
import string
V = "AEIOUYaeiouy"
C = "BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz"
def checkio(text):
words=0
text=text.replace('.', ' ').replace(',', ' ').split(' ')
for word in text:
if len(word) > 1:
rightWord = True
else:
rightWord = False
for j in range(len(word)-1):
if word[j] in V and word[j+1] in V:
rightWord = False
break
elif word[j] in C and word[j+1] in C:
rightWord = False
break
elif word[j] not in C and word[j] not in V:
rightWord = False
break
if rightWord == True:
words+=1
return words;
#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"
Nov. 6, 2016