Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ghosts Age by bartorbard
def fibo(x):
fib=[]
fib.append(0)
fib.append(1)
fib.append(1)
n=3
while n<=x:
fib.append( fib[n-1] + fib[n-2] )
n=n+1
return fib[x]
def listfibo(x):
listfib=[]
while x<22:
listfib.append(fibo(x))
x=x+1
return (listfib)
def checkio(opacitys):
listfib=listfibo(1)
opacity = opacitys
if opacity==10000:
return (0)
diff = 10000
x=0
while diff!=opacity:
x += 1
if x in listfib:
diff=diff-x
#print(diff)
else:
diff = diff+1
#print(diff)
return(x)
#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"
Dec. 4, 2016