# The Best Fit Jigsaw

**Computer Science**Level 5

We wish to design a jigsaw puzzle with square pieces, whose length/width ratio is as close as possible to \(\sqrt 2\).

For a small puzzle, we could make the puzzle \(17\times12\), because
\[\left|\left(\dfrac{17}{12}\right)^2 - 2\right| = \dfrac{1}{144}\]
is very small. Let us call a \(\ell\times w\) puzzle *good* if the difference
\[\left|\left(\dfrac \ell w\right)^2 - 2\right|\]
is less than that same expression for any puzzle with fewer pieces.

How many pieces is the largest good puzzle with less than 10000 pieces?