Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
O(1) obfuscated solution in Creative category for Ghosts Age by DiZ
import math
def checkio(l):
S=5**.5
i,l=S/2+.5,1e4-l
I=lambda s:round(i**s/S)+s-l
O=lambda s:int(math.log(s*S+.5,i))
return I(1+O(l)+(3>I(O(l))))-5if l else 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"
Feb. 12, 2014
Comments: