• + 46 comments

    For those, who, like me, struggle to understand the algorithm even after googling one. It took me time, imagination and a couple of colored pens, but I figured out the pattern. Look at this image.

    https://drive.google.com/uc?export=view&id=1t_7fU2LD06qfyIOiFTJ51X8npx0qmcca

    The pattern is that concrete elements can only be 'flipped' to certain positions. Looking at coordinates, you can always say what other elements can be placed instead of this exact element.

    So what you need to do is:

    1. Pick an element from the top left quarter.
    2. Find its 'beyond the mirror' mates.
    3. Choose the maximum element.

    And sum them up. Voila!

    The general rule:

    For every m[i][j] from the top left quarter:
    
    m[i][j] ⇌ m[i][(2n-1)-j] ⇌ m[(2n-1)-i][j] ⇌ m[(2n-1)-i][(2n-1)-j]