• + 0 comments

    To create this group for all elements in the upper-left quadrant, use 2 for loops.

    groups = [] for x in range(n): for y in range(n): groups.append([matrix[x][y], matrix[2n-1-x][y], matrix[x][2n-1-y], matrix[2n-1-x][2n-1-y]])

    Then loop through groups to find max of each list, and sum them up.