Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by Lukeram
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
LETTERS = VOWELS + CONSONANTS + "1234567890"
def checkio(text):
k=0;
text=text.upper()
tab=[]
for i in range( len(text) ) :
if text[i] not in LETTERS:
tab=tab+[text[k:i]]
k=i+1
tab=tab + [text[k::]]
Z=len(tab)
i=0
print(tab)
while i < Z:
print(tab[i])
if len(tab[i])<2:
tab.remove(tab[i])
Z=Z-1
i-=1
i+=1
LC=0
for i in tab:
Q=True
for j in range( len(i) ):
if i[0] in VOWELS:
if j%2==0 and i[j] not in VOWELS:
Q=False
if j%2==1 and i[j] not in CONSONANTS:
Q=False
elif i[0] in CONSONANTS:
if j%2==1 and i[j] not in VOWELS:
Q=False
if j%2==0 and i[j] not in CONSONANTS:
Q=False
else:
Q=False
if Q:
LC+=1
return LC
#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"
assert checkio("1st 2a ab3er root rate") == 1, "Dog, cat and human"
Nov. 24, 2016