• + 0 comments

    There seems to be an error in the hidden test case 3 and 6. Manually checked my code's answer, and it is correct.

    !/bin/python3

    import math import os import random import re import sys

    #

    Complete the 'hourglassSum' function below.

    #

    The function is expected to return an INTEGER.

    The function accepts 2D_INTEGER_ARRAY arr as parameter.

    #

    def hourglassSum(arr): # Write your code here maxSum = 0 for i in range(1,5): for j in range(1,5): maxSum = max(maxSum, (arr[i-1][j-1] + arr[i-1][j] + arr[i-1][j+1] + arr[i][j] + arr[i+1][j-1] + arr[i+1][j] + arr[i+1][j+1]))

    print(arr)
    return maxSum
    

    if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')

    arr = []
    
    for _ in range(6):
        arr.append(list(map(int, input().rstrip().split())))
    
    result = hourglassSum(arr)
    
    fptr.write(str(result) + '\n')
    
    fptr.close()