Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by freeman_lex
def checkio(S):
A, l, V = [""], 0, "AEIOUY"
for i in S:
if i.isalnum(): A[-1] += i.upper()
else: A.append("")
for m in A:
if len(m) > 1 and m.isalpha():
B = [m[j] for j in range(len(m)) if not j%2]
C = [m[j] for j in range(len(m)) if j%2]
if all([k in V for k in B]) and all([k not in V for k in C])\
or all([k in V for k in C]) and all([k not in V for k in B]): l+=1
return l
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(u"My name is ...") == 3, "All words are striped"
assert checkio(u"Hello world") == 0, "No one"
assert checkio(u"A quantity of striped words.") == 1, "Only of"
assert checkio(u"Dog,cat,mouse,bird.Human.") == 3, "Dog, cat and human"
July 26, 2014