Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by Andreas_Strus
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
text = text.upper()
text = text.replace('!',' ').replace('?',' ').replace('.',' ').replace(';',' ').replace(',',' ').split()
x = len(text)
y = 0
p = 0
for y in range(x):
t = 0
if len(text[y]) > 1:
n = 0
print(text[y], text[y][n])
for n in range(len(text[y]) - 1):
print ((text[y][n] in VOWELS and text[y][n + 1] in CONSONANTS)or (text[y][n] in CONSONANTS and text[y][n+1] in VOWELS))
if (text[y][n] in VOWELS and text[y][n + 1] in CONSONANTS)or (text[y][n] in CONSONANTS and text[y][n+1] in VOWELS):
n = n + 1
t = t + 1
if n == (len(text[y]) - 1) == t:
p = p + 1
return p
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it?") == 8, "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. 24, 2016