the_end_of_other.checkio()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
def checkio(words_set):
2
    word_list = sorted(list(words_set), key=len)
3
    return any(
4
        [
5
            word_list[i] in word_list[j][-len(word_list[i]) :]
6
            for i in range(len(word_list))
7
            for j in range(i + 1, len(word_list))
8
        ]
9
    )
10
11
12
# These "asserts" using only for self-checking and not necessary for
13
# auto-testing
14
if __name__ == '__main__':
15
    assert checkio({u"hello", u"lo", u"he"}) is True, "helLO"
16
    assert checkio({u"hello", u"la", u"hellow", u"cow"}) is False, "hellow la cow"
17
    assert checkio({u"walk", u"duckwalk"}) is True, "duck to walk"
18
    assert checkio({u"one"}) is False, "Only One"
19
    assert checkio({u"helicopter", u"li", u"he"}) is False, "Only end"
20