-1
$\begingroup$

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?

1 Answers 1

0

I have found an approach to this problem.

You can solve it by construction.

Let me give you an insight of what I have come to conclusion.

Lets say you start with a 1. It could have come from 4 grids.

10 00

00 10

01 00

00 01

Now let's define n_8 as the number of posible grids where the adyacent 2 numbers are 00 (facing the direction where you are going to insert the next number). And n_01 as the number of possible grids where the adyacent 2 numbers are 01 or 10

So, for example:

If you have a 1, and you want to add a 1 to the right. N_8 = 2 and N_1 = 2.

So, when adding a 1, you have to calculate the new N_8 and the new N_1.

I have found the formula for this case is: N_8 = N_1 + 1 N_1 = N_8 + 2

Because, adding a 1 next to a (0,0) there are always 2 posibilities. And (1,0) only 1.

Now you got a (1 1) grid.

I feel that with the propertly formulas you can build with this approach whatever grid you want.