Skip to content

Commit f19c706

Browse files
authored
Create ghos_bithdays_fibonnaci
1 parent bc1a937 commit f19c706

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

ghos_bithdays_fibonnaci

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
def fibi(n):
2+
old, new = 0, 1
3+
if n == 0:
4+
return 0
5+
for i in range(n-1):
6+
old, new = new, old + new
7+
return new
8+
9+
liczby_fib = []
10+
for i in range(28):
11+
liczby_fib.append(fibi(i))
12+
13+
14+
limit=10000
15+
solution = []
16+
for i in range(5000):
17+
if i in liczby_fib:
18+
limit-=i
19+
else:
20+
limit+=1
21+
solution.append(limit)
22+
23+
24+
def checkio(n):
25+
return solution.index(n)
26+
27+
28+
29+
#These "asserts" using only for self-checking and not necessary for auto-testing
30+
if __name__ == '__main__':
31+
assert checkio(10000) == 0, "Newborn"
32+
assert checkio(9999) == 1, "1 year"
33+
assert checkio(9997) == 2, "2 years"
34+
assert checkio(9994) == 3, "3 years"
35+
assert checkio(9995) == 4, "4 years"
36+
assert checkio(9990) == 5, "5 years"

0 commit comments

Comments
 (0)