Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Encode and check solution in Clear category for Striped Words by veky
def striped(word):
"""Is a word (encoded with d,v,c,p) striped?"""
for forbidden in "d", "v"*2, "c"*2:
if forbidden in word:
return False
return len(word) > 1
def encode(text):
"""Generate kinds of letters for text (d,v,c,p)."""
for char in text:
if char.lower() in "aeiouy":
yield "v" # vowel
elif char.isalpha():
yield "c" # consonant
elif char.isdigit():
yield "d" # digit
else:
yield "p" # punctuation (and space)
def checkio(text):
"""Number of striped words."""
encoded = "".join(encode(text))
words = encoded.split("p")
return sum(map(striped, words))
Feb. 13, 2015
Comments: