Turning coins on a chessboard

No, it's not always possible.

There's never any point to flip a row or column more than once, and the order of the moves doesn't matter.

Thus, there are only $2^n$ row flip strategies, and $2^n$ column flip strategies, yielding at most $(2^n)(2^n) = 2^{2n}$ possible strategies.

But there are $2^{n^2}$ possible positions, hence, when $n^2 > 2n$ (e.g., $n \ge 3$), not all positions can be reached from the the all-heads position. Equivalently, when $n^2 > 2n$, not all positions can reach the all-heads position.


If $n$ is even, then the number of heads never changes parity. So, if you start with an odd number of heads, you'll never finish with all heads.


Another solution using matrices:

Denote by $ A \in \mathbb R ^{n \times n}$ the matrix representing the board, where heads is represented by $-1$ and tails by $1$. Flipping the $i$-th column/row is the same as multiplying the $i$-th column/row in the matrix by $-1$. Such a move does not change the rank of the matrix, as it is the same as multiplying $A$ with a diagonal matrix $\operatorname{diag}(1, \dots, -1, \dots, 1)$ from right/left.

The configuration with all heads up has rank $1$. Thus the only configurations that can possibly be reached are those with rank $1$. Obviously there are configurations with rank $\geq 2$.