Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by saklar13
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
from string import punctuation
def checkio(text):
text = text.upper()
for f, w in zip((punctuation, VOWELS, CONSONANTS), (' ', 'v', 'c')):
for x in f:
text = text.replace(x, w)
result = 0
for word in text.split():
if len(word) > 1 and word.isalpha():
if word.find('vv') == -1 and word.find('cc') == -1:
result += 1
return result
#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"
Jan. 12, 2015