Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by kamilinho20
import re
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
helper = ''
result = 0
word = re.split("\W+", text)
for w in word:
a = 0
b = 0
if len(w) < 2:
continue
striped = False
for l in w:
if VOWELS.find(l.upper()) == -1 and CONSONANTS.find(l.upper()) == -1:
striped = False
break
if VOWELS.find(l.upper()) != -1:
a += 1
b = 0
if CONSONANTS.find(l.upper()) != -1:
b += 1
a = 0
if a == 2 or b == 2:
striped = False
break
else:
striped = True
if striped:
result += 1
return result
#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("1st 2a ab3er root rate") == 3, "Dog, cat and human"
Dec. 20, 2016