Consider the sequence of 9 non zero distinct digits arranged in a 3 by 3 grid , like
547
398
162
Clearly there are 9! (=362880) ways to do it.
If we demand that the consecutive numbers are next-door neighbours
( horizontally or vertically) like
167
258
349
then the number is significantly lower, say N.
Find N & provide your reasoning.
First, we solve by counting the placements that work. The multiplicity by rotation or reflection is given in parentheses:
(4) (4) (1)
100 000 000
000 100 010
000 000 000
| | |
(2) (2) (1) (4)
100 200 000 020
200 100 120 010
000 000 000 000
| \ x x |
| \ |
(1) (1) (2)
100 100 923
200 230 814
300 000 765
| \
(1) (1)
100 140
200 230
340 000
| |
| |
(1) (1) (1) (1)
189 187 167 145
276 296 258 236
345 345 349 987
x means "dead end"
So, the number of ways are found by multiplying the multiplicities along the three columns above for starting "1" in the: corner, side, and center:
Total = (4 * 2 * 3) + (4 * 2) + (4 * 2)
Total = 40
Next, with some clunky code, making sure all that works by also counting the total number that fill = 9!
lord@rabbit 13054 % sim
9! = 362880 Total = 40
Edited on October 27, 2022, 10:27 am