• + 0 comments

    Python 3.8+ solution:

    def flippingMatrix(matrix: list[list[int]]) -> int:
        return sum(
            max((row := matrix[i])[j], row[~j], (row := matrix[~i])[j], row[~j])
            for i, j in itertools.product(range(len(matrix) // 2), repeat=2)
        )