Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ghosts Age by CyprianSzlachciak
def czyFibo(a):
n=1
list=[1,1]
i=2
while a!=list[i-1]+list[i-2]:
d=list[i-1]+list[i-2]
list+=[d]
i+=1
if a < d: return False
return True;
def checkio(opacity):
if opacity == 10000:
return 0
elif opacity == 9999:
return 1
else:
list = [1,2]
y=2
d=10000
d-=3
while opacity != d:
y+=1
if czyFibo(y)==False:
d+=1
else:
d-=y
r=str(y)
return y
return 0
#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"
Nov. 21, 2016