Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ghosts Age by tomasz.pucka
def checkio(opacity):
Fib=[1, 1]
i=2
while(i<20):
Fib.append(Fib[i-1]+Fib[i-2])
i+=1
age=1
number=10000
if(opacity==10000): return 0
while(number!=opacity):
if(age in Fib):
number=number-age
if((age) not in Fib):
number=number+1
age+=1
return age-1
#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"
Oct. 30, 2016
Comments: