function rob(nums::Array{T,1}) where T
    table = Dict{T,UInt64}()
    function inner(nums, start, len, table)
        try
            return table[start]
        catch end

        if start == len
            table[start] = nums[start]
            return nums[start]
        elseif start == len + 1
            table[start] = 0
            return 0
        end

        a = max(
            maximum([inner(nums, x, len, table) for x in start+1:len]),
            nums[start] + inner(nums, start+2, len, table)
        )

        table[start] = a
        a
    end
    inner(nums, 1, length(nums), table)
end

using Test
@test rob([183, 219, 57, 193, 94, 233, 202, 154, 65, 240, 97, 234, 100, 249, 186, 66, 90, 238, 168, 128, 177, 235, 50, 81, 185, 165, 217, 207, 88, 80, 112, 78, 135, 62, 228, 247, 211]) == UInt64(3365)
@test rob([9, 297, 196, 336, 435, 2, 343, 159, 146, 359, 45, 470, 265, 131, 17, 271, 74, 242, 448, 402, 55, 423, 414, 240, 430, 135, 322, 468, 422, 351, 441, 463, 30, 399, 132, 439, 463, 260, 399, 32, 374, 383, 276, 166, 104, 315, 314, 445, 458, 422, 104, 251, 382, 230, 484, 127, 355, 332, 317, 362, 257, 493, 474, 401, 40, 93, 433, 464, 136, 342, 98, 159, 223, 110, 89, 47, 53, 179, 219, 314, 486, 301, 307, 453, 37, 366, 334, 355, 26, 484, 124, 408, 346, 133, 420, 280, 124, 210, 358, 140]) == UInt64(15632)

# use this to test time
# @time rob([9, 297, 196, 336, 435, 2, 343, 159, 146, 359, 45, 470, 265, 131, 17, 271, 74, 242, 448, 402, 55, 423, 414, 240, 430, 135, 322, 468, 422, 351, 441, 463, 30, 399, 132, 439, 463, 260, 399, 32, 374, 383, 276, 166, 104, 315, 314, 445, 458, 422, 104, 251, 382, 230, 484, 127, 355, 332, 317, 362, 257, 493, 474, 401, 40, 93, 433, 464, 136, 342, 98, 159, 223, 110, 89, 47, 53, 179, 219, 314, 486, 301, 307, 453, 37, 366, 334, 355, 26, 484, 124, 408, 346, 133, 420, 280, 124, 210, 358, 140, 9, 297, 196, 336, 435, 2, 343, 159, 146, 359, 45, 470, 265, 131, 17, 271, 74, 242, 448, 402, 55, 423, 414, 240, 430, 135, 322, 468, 422, 351, 441, 463, 30, 399, 132, 439, 463, 260, 399, 32, 374, 383, 276, 166, 104, 315, 314, 445, 458, 422, 104, 251, 382, 230, 484, 127, 355, 332, 317, 362, 257, 493, 474, 401, 40, 93, 433, 464, 136, 342, 98, 159, 223, 110, 89, 47, 53, 179, 219, 314, 486, 301, 307, 453, 37, 366, 334, 355, 26, 484, 124, 408, 346, 133, 420, 280, 124, 210, 358, 140, 9, 297, 196, 336, 435, 2, 343, 159, 146, 359, 45, 470, 265, 131, 17, 271, 74, 242, 448, 402, 55, 423, 414, 240, 430, 135, 322, 468, 422, 351, 441, 463, 30, 399, 132, 439, 463, 260, 399, 32, 374, 383, 276, 166, 104, 315, 314, 445, 458, 422, 104, 251, 382, 230, 484, 127, 355, 332, 317, 362, 257, 493, 474, 401, 40, 93, 433, 464, 136, 342, 98, 159, 223, 110, 89, 47, 53, 179, 219, 314, 486, 301, 307, 453, 37, 366, 334, 355, 26, 484, 124, 408, 346, 133, 420, 280, 124, 210, 358, 140])
