• + 0 comments

    Here's a python3 one-liner.

    max([sum(arr[j][i:i+3]) + arr[j+1][i+1] + sum(arr[j+2][i:i+3])
            for j in range(len(arr)-2) for i in range(len(arr[0])-1)])
    

    This code uses list comprehension to build a list of hour glass sums. For the rows where 3 values are added, I used sum(arr[row][col:col+3]) then summed all values. The code starts at i, j = 0, 0 and I used the size of the array to limit the i and j terms. Think nested loop