# Math Help - Arranging numbers in a grid

1. ## Arranging numbers in a grid

In how many different ways can you arrange the numbers 1-9 in a 3X9 grid such that each number appears exactly once in each row: and each number appears exactly once in each of the left, middle, and right 3X3 grids? Here is the grid along with one possible arrangement:

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

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

Then the total ways to arrange the numbers would be 9! for the left hand section. For the middle section would you have 9! - 3*3! and for the right section 9! - 3*6! ?

I can't seem to wrap my feeble mind around this problem.

Any hints would be greatly appreciated. Thanks.

2. Originally Posted by oldguynewstudent
In how many different ways can you arrange the numbers 1-9 in a 3X9 grid such that each number appears exactly once in each row: and each number appears exactly once in each of the left, middle, and right 3X3 grids? Here is the grid along with one possible arrangement:

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
This is a vicious problem! I hope I have the right approach to it.

Start with the top row, which can be arranged in 9! ways. Let's just pick one of those, and think about how many ways there are of filling in the rest of the grid. So take the top row to be 123456789. Suppose to start with that the first three numbers in the second row are the same as the second batch of three in the top row:

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

With 456 (in some order) in the red places, we obviously have to have 789 (in some order) in the blue places. In the middle row, the numbers 789 cannot go in the last three (purple) places, so they must go (in some order) in the green places. Then in the bottom row we have to have 123
(in some order) in the magenta places, and 456 (in some order) in the cyan places. There are 3!=6 ways of ordering a set of three numbers, and there are six coloured sets of three numbers that can each occur in any order. So that gives us a total of $6^6$ possible ways of filling in the grid with 123456789 as the top row and 456 (in some order) at the start of the second row. A similar calculation shows that there are also $6^6$ possible ways of filling in the grid with 123456789 as the top row and 789 (in some order) at the start of the second row.

Now things get more complicated. Still keeping 123456789 as the top row, suppose that the second row starts with two of the three numbers 456 together with one of the three numbers 789, say like this:

1 2 3 4 5 6 7 8 9
4 5 7 x 8 9 6 y z
6 8 9 7 y z 4 5 x

Here, I have dropped the 6 from 456, in the red batch, and replaced it with a 7. I could have dropped any one of the three numbers 456, and replaced it with any one of the three numbers 789. That gives a total of 9 choices so far. In the green places, we must have 8 and 9 together with one of the numbers 123. That gives another three-way choice, bringing the number of choices up to 27. The remaining numbers must then go into the coloured batches as shown, where xyz are the numbers 123 (in some order). For each of those 27 choices, we have again have $6^6$ possible arrangements by shuffling the numbers within each coloured batch.

Finally, if the red batch in the second row has just one of the numbers 456 together with two of the numbers 789 then we have the same calculation as in the previous paragraph, with a total of $27\times6^6$ arrangements.

Putting it all together there are $6^6(1+27+27+1) = 2,612,736$ possible arrangements for any given choice of top row. Thus the answer to the question should be $2,612,736\times9! = 948,109,639,680$.

3. Again thank you so much for your help! I am trying to get a head start on my combinatorics class for the summer as I am attempting to take two math courses during the short summer session. The help I am getting is invaluable as is the ibuprofen I am taking while reviewing these problems.