Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ghosts Age by welv
def isFib(number):
i = 0
i2 = 1
while i2 < number:
temp = i
i = i2
i2 += temp
if i2 == number:
return True
else:
return False
def checkio(opacity):
age = 0
testOpacity = 10000
while testOpacity != opacity:
age += 1
if isFib(age) == True:
testOpacity -= age
else:
testOpacity += 1
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. 20, 2017