def is_fibonacci(num):
cur = 0
prev1 = 1
prev2 = 0
while cur < num:
cur = prev1 + prev2
prev2 = prev1
prev1 = cur
if num == cur:
return True
else:
return False
def checkio(opacity):
if opacity == 10000:
return 0
cur = 10000
last_fibonacci = 1
for yrs in range(1, 5000):
if is_fibonacci(yrs) == True:
if cur - yrs == opacity:
return yrs
else:
cur -= yrs
last_fibonacci = yrs
else:
if cur + 1 == opacity:
return yrs
else:
cur += 1