Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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


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

not allowed

Click here to view the solution

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?

share|cite|improve this question

1 Answer 1

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.

share|cite|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.