Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by tokyoamado
import re
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
template = r'([%s][%s])+[%s]?'
pattern_a = template % (VOWELS, CONSONANTS, VOWELS)
pattern_b = template % (CONSONANTS, VOWELS, CONSONANTS)
isStripe = re.compile(r'(%s|%s)$' % (pattern_a, pattern_b))
def checkio(text):
words = re.split(r'[ ,.?\t\n]', text.upper())
return sum(bool(isStripe.match(word)) for word in words)
Nov. 18, 2017