Question: My young daughter and I love doing jigsaw puzzles together. The other day, we had a quite difficult one: 7 by 7 pieces!

We started as usual by splitting the pieces into 2 stacks: the edge pieces on one side, the middle pieces on the other side.

Before putting the edges together, we noticed that there were almost the same number of pieces in each stack:

![Our 7x7 puzzle](https://i.imgur.com/kcL6f3Y.png)

I wondered then... our puzzle collection is huge! We have all the possible sizes, from 1x2 to 100x100 pieces.

**Can we find one (or even more?) in our collection containing exactly the same number of edges pieces and middle pieces?**

Answer: 
What you're looking for are numbers $X$ and $Y$ where $2X + 2(Y-2) = (X-2)\*(Y-2)$. This is generalized; a few possible (and practical) solutions would be:

* $5$ by $12$, with $30$ of both edge and middle pieces.
* $6$ by $8$, with $24$ of both edge and middle pieces.
Our goal is to find such $n$ and $m$ that $nm = 2(n-2)(m-2)$. They can't be equal of course.

Assuming $n<m$, then $\dfrac n{n-2} > \sqrt2$, so $n<8$. 

Then again, $2(n-2) > n$, therefore $4<n<8$. 

The equality $\frac{2n-4}n = \frac m{m-2}$ can be modified as $\frac{n-4}n = \frac2{m-2}$, so $\frac{2n}{n-4}$ must be an integer equal to $m-2$, making 8 divisible by $n-4$. The latter can be 1 or 2, so either $n=5, m=12$ or $n=6, m=8$.

Disclaimer: I know I could just try seeing if it can be done for all 3 possible values of $n$ after narrowing it down, but didn't feel like it.