Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ghosts Age by pawel1337
import math
def fi():
f = [0, 1]
current = 0
counter = 2
while (current <= 10000):
current = f[counter-1] + f[counter-2]
f.append(current)
counter += 1
return f
def checkio(opacity):
f = fi()
age = 0
remaining = 10000
while (remaining != opacity):
age += 1
if age in f:
remaining = remaining - age
else:
remaining += 1
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"
Nov. 5, 2016