Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Ghosts Age by _Chico_
def fibonacci(n):
a, b = 0, 1
while n > 0:
a, b = b, a + b
n -= 1
yield a
def checkio(_opacity):
opacity = 10000
opacity_age = {opacity:0}
for i in range(1, 5000):
if i in list(fibonacci(100))[:20]:
opacity -= i
else:
opacity += 1
opacity_age[opacity] = i
return opacity_age.get(_opacity)
#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"
May 10, 2021
Comments: