I would like to know how one can solve the following optimization problem using Sage.
I would like to have a matrix where every element is an integer from 0 to 9. One can read numbers from the matrix by choosing the starting element and direction from one of the eight direction (horizontal, vertical, diagonal) and go to that direction 0 to 5 steps and concatenate the numbers.
For example, one can read the squares of 1 to 10 from the following matrix:
0 0 1 8 2
3 6 4 9 5
Now the problem is to find an $n\times m$ matrix with digits from 0 to 9 where one can read the squares of 1 to 100 in a way described above where $nm$ is the smallest possible. How can I do that on Sage? I would like to see how good result we can achieve.