We have a grid of size Nx N. Each cell of the grid initially contains a zero(0) or a one(1).
The parity of a cell is the number of 1s surrounding that cell. A cell is surrounded by at most 4 cells (top, bottom, left, right).
Suppose we have a grid of size 4x 4:
1 |
0 |
1 |
0 |
The parity of each cell would be |
1 |
3 |
1 |
2 |
1 |
1 |
1 |
1 |
2 |
3 |
3 |
1 |
|
0 |
1 |
0 |
0 |
2 |
1 |
2 |
1 |
|
0 |