Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Striped Words by krzysztof.gonda
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def hasNumbers(inputString):
return any(char.isdigit() for char in inputString)
def checkio(text):
count = 0
import re
list = re.sub("[^\w]", " ", text.lower()).split()
for x in list:
check = 1
if (hasNumbers(x)):
check = 0
if(len(x)!=1):
if x[0] in VOWELS.lower():
for y in range (1,len(x)):
if (y%2):
if x[y] in VOWELS.lower():
check = 0
else:
if x[y] in CONSONANTS.lower():
check = 0
else:
for y in range (1,len(x)):
if (y%2):
if x[y] in CONSONANTS.lower():
check = 0
else:
if x[y] in VOWELS.lower():
check = 0
else:
check = 0
count += check
return count
#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. 18, 2017