Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear solution in Clear category for Striped Words by intspt
# migrated from python 2.7
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
MARKS = ',.?'
def checkio(text):
for char in MARKS:
text = text.replace(char, ' ')
words = [x for x in text.split() if len(x) > 1]
cnt = 0
for w in words:
a, b = w[::2].upper(), w[1::2].upper()
if set(VOWELS) >= set(a) and set(CONSONANTS) >= set(b):
cnt += 1
elif set(VOWELS) >= set(b) and set(CONSONANTS) >= set(a):
cnt += 1
return cnt
#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"
Aug. 17, 2014
Comments: