Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Ghosts age BOOO solution in Clear category for Ghosts Age by graffme
def F(n):
#policz liczby Fibonacciego
# jeśli n = 0 to 1, jeśli n = 1 to 1 inaczej wzór F(n) = F(n-1)+ F(n-2)
fibnum = [1, 1]
for i in range(2, n + 1):
fibnum.append(fibnum[-1] + fibnum[-2])
#print(fibnum)
return fibnum
def checkio(opacity):
#policz wiek ducha
#robocza opacity = 10000 i wiek = 0
#dopóki robocza opacity != opacity to
#jeśli wiek jest liczbą fibonacciego to dodaj 1 do wieku
#jak nie to odejmij
fibList = F(19)
ghostage = 0
tempopacity = 10000
while opacity != tempopacity:
ghostage += 1
if ghostage in fibList:
tempopacity -= ghostage
else:
tempopacity += 1
return ghostage #BOOO
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(10000) == 0, "Newborn"
assert checkio(9999) == 1, "1 year"
assert checkio(9997) == 2, "2 years"
assert checkio(9994) == 3, "3 years"
assert checkio(9995) == 4, "4 years"
assert checkio(9990) == 5, "5 years"
Jan. 11, 2017