Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
newbie solution in Clear category for Ghosts Age by ewa_c
fib=[]
fib.append(1)
fib.append(1)
for x in range(21):
if x>1:
fib.append(fib[x-2]+fib[x-1])
#print(fib)
def checkio(opacity):
list = []
list.append(10000)
# print(list)
for i in range(10000):
if i>=1 and i in fib:
list.append(list[i-1]-i)
elif i>=1:
list.append(list[i-1]+1)
#print(list)
for i in range(10001):
if opacity==list[i]:
if i<5000:
return i
else:
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"
Nov. 20, 2016