Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ghosts Age by voxes96
def fibonacci(n=22):
arr = [1,1]
for i in range(2,n):
arr.append(arr[i-1]+arr[i-2])
return arr
def checkio(opacity):
year = 0
res = 10000
fib = fibonacci(22)
for i in range(5000):
if(res == opacity):
return year
year = year + 1
if(year in fib):
res = res - year
else:
res = res + 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"
Nov. 4, 2016