[Math] How many different ways can the numbers 1-9 be arranged in a 3×9 grid

combinatoricspermutations

I wasn't able to find anything similar, so here is the full question:

How many different ways can the numbers 1-9 be arranged in a 3×9 grid so that each number appears exactly once in each row and each number appears exactly once in each of the left, middle, and right 3×3 sub-grids? Here is an example of one such grid:

| 2 | 7 | 1 || 3| 5 | 9 || 6| 4 | 8 |
| 4 | 3 | 8|| 6| 7 | 2 || 1 | 5 | 9 |
| 5 | 6 | 9|| 1 | 4 | 8|| 2 | 3 | 7 |

My first instinct is to find how many total boards there are without any restrictions, subtract the boards with duplicates in any lines, and then subtract the boards with duplicates in any sub-grid. To find the total number of boards I assume there are 9! ways to permute each line and 3! ways to arrange them so there are 9!*3! boards. However, I'm not sure where to go from here, or if I'm even on the right track. I would be grateful for any assistance if possible.

Best Answer

This paper provides a method to enumerate the number of sudoku grids.

In sections $1$ and $2$ of the paper, they first enumerate the number of ways of filling the top three rows, which matches the problem you ask above.

They find that when the first block is in canonical form there are:

$$2\times (3!)^6+18\times 3\times (3!)^6=2612736$$

In order to enumerate the number of arrangements where the first block is not in canonical form, we may impose a relabeling of the numbers which can occur in $9!$ ways, and for each arrangement with a canonical first block each relabeling of which will produce another unique arrangement. Noting then that all arrangements can be arrived at in this fashion, we have then a final total of:

$$(2\times (3!)^6+18\times 3\times (3!)^6)\times (9!) = 56(3!)^69!=948109639680$$


A brief look at the method used was to first reduce the problem to that which involves only arrangements with the first block in the form $\begin{bmatrix} 1&2&3\\4&5&6\\7&8&9\end{bmatrix}$.

From here, they make the simplification that we just count the cases that use a $4$ in the first row second block, since any arrangement that has a $4$ in the first row third block is in direct bijection with those in the cases we count, so by counting that simplified case we can correct our count by multiplying by two.

If it happened to be that $\{4,5,6\}$ are the numbers (not necessarily in that order) in the first row second block, then that immediately implies how each row will look, forcing it to be $\begin{array}{|ccc|ccc|ccc|}\hline 1&2&3&\{4,&5,&6\}&\{7,&8,&9\}\\4&5&6&\{7,&8,&9\}&\{1,&2,&3\}\\7&8&9&\{1,&2,&3\}&\{4,&5,&6\}\\\hline\end{array}$

Deciding which block the $4$ actually is in, as well as how to arrange each bracketted set of three numbers in the above arrangement gives the $2\times (3!)^6$ term in the above count (or equivalently the $2\times (3!)^6\times 9!$ term in the corrected count).

The later cases are counted similarly and can be found in the linked paper, but involve what happens if you have one "large" or two "large" numbers in the same set of three as the $4$ in the first row.