This question comes from a programming challenge, but I want to take a mathematical approach to it if possible.
Example starting state: $$ \pmatrix{ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 } $$ The following grid is determined by taking & applying the rules to 2 x 2 subsets of the starting state. The resulting grid will always be 1 column and 1 row smaller than its originating grid.
If there is a single 1 in the 2 x 2 subset, the result will be a 1. All other cases is a 0. $$ \pmatrix{ 0 & 1 \\ 0 & 0} = 1 \quad\quad \pmatrix{ 1 & 0 \\ 0 & 1} = 0 $$
and so on.
So the example results in the following grid: $$ \pmatrix{ 1 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 1 } $$ I feel like it could be figured using some permutations and I've established that there are 4 possible configurations of the 2 x 2 subset to result in a 1 and 12 which result in a 0. Due to each position being dependent on the adjacent positions, though, I haven't found a good formula to determine the number of possible states which result in the given state. The number of different grids that turn into the 3x3 grid is 4. The size of the grid to be given can range from 3x3 to 9x50.
Any suggestions for ways to break this down into simpler sub problems to formulate?