Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
O(n) (1 regex) solution in Uncategorized category for Striped Words by DiZ
from re import I, findall
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
pattern = r'(?:\b(?:[{}][{}])+[{}]?\b)'
regex = '({}|{})'.format(*[pattern]*2).format(*[VOWELS, CONSONANTS]*3)
return len(findall(regex, text, I))
#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"
Dec. 23, 2013
Comments: