Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Ghost age solution in Clear category for Ghosts Age by kristof.barbaix
def checkio(opacity):
co=10000
fibonacci = [1,2]
for i in range(2,25):
fibonacci.append(fibonacci[i-2] + fibonacci[i-1])
print(fibonacci)
if opacity == 10000:
return 0
for x in range(1,5001):
if x in fibonacci:
co = co - x
else:
co = co + 1
print(x,co)
if co == opacity:
return x
return 0
#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"
July 30, 2015
Comments: