Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ghosts Age by Machinero
def fib(n):
if(n==0):
return 0
elif (n<3):
return 1
else:
return fib(n-2)+fib(n-1)
def checkio(opacity):
fib_numbers = []
age = 0
for i in range(20):
fib_numbers.append(fib(i))
x = 10000
for i in range(x):
if opacity != x:
if i in fib_numbers:
x -= i
else:
x += 1
age = i
return age
#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. 12, 2017