# How to solve 5x5 grid with 16 diagonals?

I have a grid 5x5 and I have to fill 16 little squares with a diagonal

Rules

• You cannot place more than 1 diagonal in each square
• The diagonals cannot touch each other (example bellow)

But what I seek here is a mathematical solution for this puzzle, I don't even know where to start looking for information.

Can someone explain how do I solve this puzzle using equations?

-

Think of it this way: You have a 5x5 array, and you need to fill it with values 0, 1, or -1, with three restrictions:

1. The cells sharing an edge with a cell with a $\pm 1$ cannot contain a $\mp 1$.
2. If a cell contains a 1, the adjacent cells to the top-left and bottom-right cannot also contain a 1.
3. If a cell contains a -1, the adjacent cells to the bottom-left and top-right cannot also contain a -1.

Here, cells containing a "1" have a diagonal running top-left to bottom-right, and cells containing a "-1" have a diagonal running the other way. Cells containing 0 do not have a diagonal at all.

So, for the example grid you provide, you start with the grid:

$$\begin{matrix}0&0&-1&0&0\\0&-1&0&-1&1\\0&0&0&0&0\\0&0&0&0&0\\0&0&0&0&0\end{matrix}$$

I don't think there's "a mathematical solution" to it - that is, I doubt that one could immediately find the "right answer" without some level of trial and error. But it does give a good starting point to automating the search, if you want to try solving it computationally.

-
Maybe the $+1$ cells should be those whose diagonal slope is positive (from lower left to upper right). That is only a suggestion since positive slope diagonals would be naturally associated to a positve number. But the restatement of the problem is nice, +1. –  coffeemath Mar 24 '13 at 8:54