Reves Puzzle by heap

h = {}
def reves(n):
    if n in h:
        return h[n]
    elif n < 2:
        return 2**n - 1
    else:
        h[n] = min([2 * reves(n-i) + 2**i-1 for i in range(1,n)])
        return h[n]

if __name__ == '__main__':
    for n in range(192):
        print(reves(n))

    

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page