Test Setup Failed
Push — master ( a07055...ba0340 )
by Ken M.
54s
created

fib_to()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
def fib_to(n):
2
    fibs = [1, 1]
3
    for i in range(2, n + 1):
4
        fibs.append(fibs[-1] + fibs[-2])
5
    return fibs
6
7
8
def checkio(opacity):
9
    age = 0
10
    opacity_left = 10000
11
    fib_numbers = fib_to(20)
12
    while opacity != opacity_left:
13
        age += 1
14
        if age in fib_numbers:
15
            opacity_left -= age
16
        else:
17
            opacity_left += 1
18
    return age
19
20
21
# These "asserts" using only for self-checking and not necessary for
22
# auto-testing
23
if __name__ == '__main__':
24
    assert checkio(10000) == 0, "Newborn"
25
    assert checkio(9999) == 1, "1 year"
26
    assert checkio(9997) == 2, "2 years"
27
    assert checkio(9994) == 3, "3 years"
28
    assert checkio(9995) == 4, "4 years"
29
    assert checkio(9990) == 5, "5 years"
30