Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by Haradd
VOWELS = "aeiouyAEIOUY"
CONSONANTS = "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ"
def separate(text):
s=[]
pom=""
for w in text:
if (w in VOWELS)==True or (w in CONSONANTS)==True or w.isdigit()==True:
pom=pom+w
else:
if w==" "or w in ['.',',']:
if pom.isalpha():
s.append(pom)
pom=""
s.append(pom)
return s
for w in s:
if w.isdigit()==True:
s=s.replace(w,"")
return s
def stripp(text):
if len(text)<=1:
return False
pre=False
if text[0] in VOWELS:
pre=True
else:
pre=False
text=text[1:]
a=True
for i in range(len(text)):
a=text[i] in VOWELS
if a==pre:
return False
pre=a
return True
def checkio(text):
c=0
text=separate(text)
for w in text:
if stripp(w)==True:
c+=1
return c
#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. 7, 2016