| Total Complexity | 16 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | VOWELS = "AEIOUY" |
||
| 2 | CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ" |
||
| 3 | |||
| 4 | |||
| 5 | def split_text(text): |
||
| 6 | result = [] |
||
| 7 | temp_text = '' |
||
| 8 | for i in text: |
||
| 9 | if i.isalpha() or i.isdigit(): |
||
| 10 | temp_text += i.upper() |
||
| 11 | else: |
||
| 12 | result.append(temp_text) |
||
| 13 | temp_text = '' |
||
| 14 | if temp_text: |
||
| 15 | result.append(temp_text) |
||
| 16 | return [i for i in result if i] |
||
| 17 | |||
| 18 | |||
| 19 | def checkio(text): |
||
| 20 | counter = 0 |
||
| 21 | for j in split_text(text): |
||
| 22 | not_striped = True |
||
| 23 | if len(j) == 1: |
||
| 24 | not_striped = False |
||
| 25 | for i in zip(j, j[1:]): |
||
| 26 | if (i[0] in VOWELS + CONSONANTS) and (i[1] in VOWELS + CONSONANTS): |
||
| 27 | if (i[0] in CONSONANTS and i[1] in CONSONANTS) or ( |
||
| 28 | i[1] in VOWELS and i[0] in VOWELS |
||
| 29 | ): |
||
| 30 | not_striped = False |
||
| 31 | break |
||
| 32 | else: |
||
| 33 | not_striped = False |
||
| 34 | if not_striped: |
||
| 35 | counter += 1 |
||
| 36 | return counter |
||
| 37 | |||
| 38 | |||
| 39 | # These "asserts" using only for self-checking and not necessary for |
||
| 40 | # auto-testing |
||
| 41 | if __name__ == '__main__': |
||
| 42 | assert checkio(u"My name is ...") == 3, "All words are striped" |
||
| 43 | assert checkio(u"Hello world") == 0, "No one" |
||
| 44 | assert checkio(u"A quantity of striped words.") == 1, "Only of" |
||
| 45 | assert checkio(u"Dog,cat,mouse,bird.Human.") == 3, "Dog, cat and human" |
||
| 46 |