Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Fibonaccis brains solution in Clear category for Ghosts Age by ZweiStein
def undead_fibonacci(hunger, EatingBrains = True):
list_of_brains_eaten = [0,1]
seconds_eating = 2
while EatingBrains == True:
list_of_brains_eaten.append(list_of_brains_eaten[seconds_eating-2]+
list_of_brains_eaten[seconds_eating-1])
if list_of_brains_eaten[seconds_eating] >= hunger: break
seconds_eating += 1
print("FIBONACCI WANTS MORE BRAINS!!!")
return list_of_brains_eaten
def ghost_opacities(max_age, list_of_brains_eaten_by_undead_fibonacci):
ghost_opacities_list = [10000]
for i in range(1, max_age):
opacity = ghost_opacities_list[i-1] + (-i if i in list_of_brains_eaten_by_undead_fibonacci else 1)
ghost_opacities_list.append(opacity)
print("BOOOO!")
return ghost_opacities_list
list_of_brains_eaten_by_undead_fibonacci = undead_fibonacci(5000)
ghost_opacities_list = ghost_opacities(5000, list_of_brains_eaten_by_undead_fibonacci)
def checkio(opacity):
ghost_age = ghost_opacities_list.index(opacity)
return ghost_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"
June 20, 2019