Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Roguer Roguer solution in Clear category for Striped Words by Adrian_Mizielinski
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
SEPARATISTS =".,?"
def isStriped(word):
counter = -1
chars=0
for ch in word:
if counter == -1:
if ch in VOWELS:
counter=0
char=1
elif ch in CONSONANTS:
counter=1
char=1
else:
return False
else:
if counter == 0 and ch in CONSONANTS:
counter=1
char=char+1
elif counter == 1 and ch in VOWELS:
counter=0
else:
return False
if len(word)!=1:
return True
def checkio(text):
for separatist in SEPARATISTS :
text=text.replace(separatist," ")
words=text.split()
counter=0
for word in words:
if isStriped(word.upper()):
counter=counter+1
return counter
#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. 3, 2016