Suppose we have an m × n grid such that each element is a base 10 digit. We can read the numbers from such a grid so that we fix a starting element, go to one of the eight nearest coordinates and maintain that direction for zero to five steps. This allows you to read a one to five digit number from a grid if you concatenate the digits.
Your task is to write a program finding the smallest m × n grid from which the squares of the numbers 1 to 100 (inclusive) can be read.
For example, if the grid is:
then the squares of
10 can be read from it, but, for example,
121 is missing. In this rectangle m × n = 2 × 5 = 10.
The winner is the code which generates the smallest grid.