Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by ys1029.f.snw.t.ssk
import re
def checkio(text):
count = 0
word_list = re.split(r"\W+", text)
check_strip = re.compile(r"^([AEIOUY][BCDFGHJKLMNPQRSTVWXZ])+[AEIOUY]?$|^([BCDFGHJKLMNPQRSTVWXZ][AEIOUY])+[BCDFGHJKLMNPQRSTVWXZ]?$", re.I)
for word in word_list:
count += 1 if bool(check_strip.findall(word)) else 0
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"
Oct. 22, 2017