Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Striped Words by shota243
import re
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
V = re.compile('[' + VOWELS + r']+\Z', re.I) # string with vowels only
C = re.compile('[' + CONSONANTS + r']+\Z', re.I) # string with consonants only
W = re.compile('[0-9A-Za-z]+') # separating with punctuations
def checkio(text):
return len([ w for w in W.findall(text)
if V.match(w[::2]) and C.match(w[1::2]) or
V.match(w[1::2]) and C.match(w[::2]) ])
#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"
April 3, 2014