Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First - use formula solution in Speedy category for Ghosts Age by shellaylee
def checkio(opacity):
def memo(f):
cache = {}
def _f(x):
if x not in cache: cache[x] = f(x)
return cache[x]
return _f
@memo
def fib(n):
if n < 3: return n
else: return fib(n-1) + fib(n-2)
s = 10000 - opacity
if s == 0: return 0
n = 0
while True:
n += 1
s0 = fib(n+1)+n-2
if s <= s0: return fib(n) + (s0 - s)
#These "asserts" using only for self-checking and not necessary for auto-testing
April 21, 2014
Comments: