= Solution
For a nonnegative order, first enumerate every possible row and then every possible ordered selection of rows:
``
squares :: Int -> [[[Int]]]
squares n
| n < 0 = error "negative order"
| otherwise = cp (replicate n (cp (replicate n [1..n])))
``
Every one of the $n^2$ positions chooses one of $n$ symbols independently. Consequently the enumeration contains \b[$n^{n^2}$] candidate squares for $n\geq1$, each exactly once. The conventional order-zero extension produces one empty square. This is generation only; repeated symbols have not yet been rejected.
Back to article page