• + 0 comments
    def hourglassSum(arr):
        # Write your code here
        max_sum = float("-inf")
        for i in range(0, 4):
            for j in range(0, 4):
                top = arr[i][j] + arr[i][j+1] + arr[i][j+2]
                middle = arr[i+1][j+1]
                buttom = arr[i+2][j] +arr[i+2][j+1] + arr[i+2][j+2]
                hg_sum = top + middle + buttom
                if hg_sum > max_sum:
                    max_sum = hg_sum
        return max_sum