Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Striped Words by lazzaro.mike
import re
vow = "AEIOUY"
con = "BCDFGHJKLMNPQRSTVWXZ"
pat = r"([%s][%s])+[%s]?$|([%s][%s])+[%s]?$" % (con, vow, con, vow, con, vow)
def checkio(text):
filter = re.compile(pat, re.I).match
striped = [ ( word, m.group() ) for word in re.findall(r"[\w]+",text) for m in (filter(word),) if m ]
return len(striped)
#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. 9, 2013
Comments: