Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Fibonacci age solution in Clear category for Ghosts Age by Seaclaid
def checkio(opacity):
age=0
fn_2=0
fn_1=1
fn=[0]
tab_opa=[10000]
years=[0]
for i in range(19):
fn=fn+[fn_2+fn_1]
fn_2=fn_1
fn_1=fn[i+1]
for i in range(0,5001):
if (i in fn)==True:
temp=tab_opa[i]-i
else:
temp=tab_opa[i]+1
tab_opa=tab_opa+[temp]
years=years+[i]
age=years[tab_opa.index(opacity)]
print(age)
return 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"
Jan. 13, 2017