Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by szymonkukla1
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def slowo(x):
f = ['a', 'e', 'i', 'o', 'u', 'y']
liczba = ['1','2','3','4','5','6','7','8','9','0']
m = 0
if(len(x) <= 1):
return 0
else:
while(m < len(x) - 1):
if(x[m] in liczba or x[m+1] in liczba):
return 0
if(x[m] in f and x[m+1] in f):
return 0
else:
if(x[m] not in f and x[m+1] not in f):
return 0
m += 1
return 1
def checkio(text):
text = text.replace('.',' ')
text = text.replace(',',' ')
text = text.replace(';',' ')
text = text.replace('?',' ')
x = text.lower().split(' ')
print(x)
i = 0
liczba = 0
while(i < len(x)):
if(slowo(x[i]) == 1):
liczba += 1
i += 1
return(liczba)
#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("1st 2a ab3er root rate") == 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. 20, 2016