Test Setup Failed
Push — master ( 31e3bb...9e1e94 )
by Ken M.
59s
created

is_word()   A

Complexity

Conditions 2

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
def is_word(x):
2
    return 1 if x.isalpha() else 0
3
4
5
def checkio(words):
6
    word_list = [is_word(i) for i in words.split()]
7
    consecutive_words = [sum(word_list[i:i + 3])
8
                         for i in range(len(word_list))
9
                         if word_list[i]]
10
    return any([True for i in consecutive_words if i >= 3])
11
12
13
# These "asserts" using only for self-checking and not necessary for
14
# auto-testing
15
if __name__ == '__main__':  # pragma: no cover
16
    assert checkio(u"Hello World hello") is True, "Hello"
17
    assert checkio(u"He is 123 man") is False, "123 man"
18
    assert checkio(u"1 2 3 4") is False, "Digits"
19
    assert checkio(u"bla bla bla bla") is True, "Bla Bla"
20
    assert checkio(u"Hi") is False, "Hi"
21