• + 0 comments

    def hourglassSum(arr): addn=[] for i in range(6): for j in range(6): top=arr[i][j]+arr[i][(j+1)%6]+arr[i][(j+2)%6] middle=arr[(i+1)%6][(j+1)%6] bottom=arr[(i+2)%6][j]+arr[(i+2)%6][(j+1)%6]+arr[(i+2)%6][(j+2)%6] add=top+bottom+middle addn.append(add)

    return max(addn)
    

    This is my attempt. but it doesnt pass all testcases for some reason. can anyone explain?