A Transformation of a cross-shaped grid filled with 1s (Proof of impossibility?)

First, the case for grid size 2017.

Consider a grid of size $n > 3$. Reusing your drawing, consider the cells colored in red and yellow for any of the four sides of the grid:

enter image description here

Let us number those colored cells starting from one red cell and ending to the other red cell with indexes $1, \ldots, \frac{n-1}{2}$, so that cell $1$ and $\frac{n-1}{2}$ are the red ones. Now define $\pi_1, \ldots, \pi_{\frac{n-1}{2}}$ the required number of transformations applied on the cells $1, \ldots, \frac{n-1}{2}$ (with the center of the 3 sized sub-cross on the cell).

$\pi_1$ and $\pi_{\frac{n-1}{2}}$ must be odd, because the corner cells are reachable only from cells $1$ and $\frac{n-1}{2}$ respectively. Then $\pi_2$ and $\pi_{\frac{n-3}{2}}$ must be even, because e.g. the border cell reachable from cell $1$ and $2$ must total an odd number of transformations, thus $\pi_1+\pi_2$ must be odd and similarly on the other side. We can continue the process along the side alternating even and odd transformations.

There are $\frac{n-1}{2}-2 = \frac{n-5}{2}$ yellow cells between the two red cells. If that number is even and it is for $n=2017$ but not for $n=7$, we will end up with the two cells $\frac{n-1}{4}$ and $\frac{n+3}{4}$ with $\pi_{\frac{n-1}{4}}$ and $\pi_{\frac{n+3}{4}}$ both even or both odd and thus $\pi_{\frac{n-1}{4}} + \pi_{\frac{n+3}{4}}$ even, so that the corresponding border cell, reachable from those cells, cannot be changed to $-1$.

Regarding the case $n=7$, consider the cells colored as below:

enter image description here

and with the usual notation, define $\pi_r$ the number of transformations applied on the red cells, and similarly $\pi_y$ for the yellow cells, $\pi_{p1}$ to $\pi_{p4}$ for the pink cells (choose whatever order you like), $\pi_g$ for the green cell.

$\pi_r$ must be odd, then $\pi_y$ must be even, as said above. Then the only way to have the pink cell $1$ at $-1$ is to have both $\pi_{p1}$ and $\pi_g$ odd or even, and similarly for pink cells $2,3,4$, therefore all pink cells must be odd or even, but this makes impossible changing the yellow cells to $-1$.

Maybe with a little more effort this can be extended for any other odd $n > 3$ with $\frac{n-1}{2}$ odd.


For each tile that is not at the edge we can apply the transformation $\pi$ centered at that tile; I'll call such a tile 'transformed'. Because transforming a tile twice is the same as not transforming it at all, it suffices to consider which tiles to transform once, and which not to transform.

Consider one edge of the diamond, say the top left edge. It contains $1009$ tiles, and the next 'row' of adjacent tiles contains $1008$ tiles. For the two tiles at the ends of the edge (i.e. at the corners) to be flipped, we must transform the unique adjacent tile to each corner. These are the first and last tiles of the row of $1008$ adjacent tiles. Every other tile on the edge has precisely two tiles adjacent to it; to flip such a tile we must transform precisely one of these two adjacent tiles. This holds for every tile on the edge, and so the tiles of the adjacent row alternate between having to be transformed and not transformed. But the first and last tile, i.e. the $1$st and $1008$th tile, are both transformed, a contradiction.

This shows that it is impossible to flip all tiles by means of these transformations.