Mirror Grid

You are given a square grid with n rows and n columns, where every cell holds either 0 or 1. The grid is called a mirror grid when rotating it by 90, 180, or 270 degrees produces exactly the same grid.

You may flip any cell from 0 to 1 or from 1 to 0. Return the minimum number of flips needed to turn the given grid into a mirror grid.

Rotating the grid maps each cell to three other cells, and those four positions always form one cycle. For every cycle, all four cells must end up with the same value, so the cheapest choice is the value that already appears most often in the cycle.

Examples
Input: [1,2,3]
Output: 0
Hints

Mirror Grid

You are given a square grid with `n` rows and `n` columns, where every cell holds either `0` or `1`. The grid is called a mirror grid when rotating it by 90, 180, or 270 degrees produces exactly the same grid.