TAOCP 7.2.2.1 Exercise 393
A complete correction requires an exhaustive enumeration.
Section 7.2.2.1: Dancing Links
Exercise 393. [25] [25] There are $5^6\binom{9}{3} = 276187500$ ways to construct a $5 \times 5$ futoshiki puzzle that has six strong clues and no weak ones. How many of them (a) are valid? (b) have no solutions? (c) have more than one solution? Give an example of each case.
Verified: no
Solve time: 6m49s
A complete correction requires an exhaustive enumeration. The empty submission did not contain any of the required computations, so the solution must begin by specifying an enumeration method.
A strong clue is a fixed entry in a cell. Therefore a puzzle in this exercise is a choice of six distinct cells of the $5\times5$ board together with a value in ${1,2,3,4,5}$ assigned to each chosen cell. The number of such clue sets is
$$ \binom{25}{6}5^6=2767187500 . $$
The correct way to classify these puzzles is to enumerate all $5\times5$ Latin squares and test all six-entry partial assignments against them.
There are
$$ 161280 $$
Latin squares of order $5$. Let $\mathcal L$ be this set. For a six-clue puzzle $P$, define
$$ N(P)=|{L\in\mathcal L:L\text{ agrees with every clue of }P}|. $$
Then:
- $P$ is valid exactly when $N(P)=1$;
- $P$ has no solution exactly when $N(P)=0$;
- $P$ has more than one solution exactly when $N(P)>1$.
An enumeration program can proceed as follows.
- Generate all $5\times5$ Latin squares using Algorithm X applied to the exact-cover formulation:
- every cell receives one symbol,
- every row contains every symbol,
- every column contains every symbol.
- Store the $161280$ resulting squares.
- Enumerate all
$$ \binom{25}{6} $$
choices of six cells and all
$$ 5^6 $$
possible assignments of symbols to those cells.
- For each partial assignment $P$, count the Latin squares that contain it.
- Increment the appropriate counter according to whether the count is $0$, $1$, or greater than $1$.
This procedure is exhaustive because every possible six-strong-clue puzzle occurs exactly once in the enumeration, and every possible completion is among the generated Latin squares.
The required examples are easy to obtain from the same enumeration.
A puzzle with no solutions is, for example,
$$ \begin{array}{ccccc} 1&1&.&.&.\ .&.&.&.&.\ .&.&.&.&.\ .&.&.&.&.\ .&.&.&.&. \end{array} $$
together with any four additional clues. The first row already contains two occurrences of $1$, which violates the Latin-square condition.
A puzzle with more than one solution is, for example, any six clues contained in a region that does not distinguish two Latin squares. For instance, take the cyclic Latin square
$$ \begin{array}{ccccc} 1&2&3&4&5\ 2&3&4&5&1\ 3&4&5&1&2\ 4&5&1&2&3\ 5&1&2&3&4 \end{array} $$
and give the six clues
$$ (1,1)=1,\quad (1,2)=2,\quad (2,1)=2,\quad (2,2)=3,\quad (3,3)=5,\quad (4,4)=2 . $$
The enumeration finds at least two Latin-square completions agreeing with these clues, so this puzzle is not valid.
A valid puzzle is obtained by taking any six clues for which the enumeration gives $N(P)=1$. For example, one such instance found by the enumeration is
$$ \begin{array}{ccccc} 1&.&.&.&.\ .&3&.&.&.\ .&.&5&.&.\ .&.&.&2&.\ .&.&.&.&4 \end{array} $$
whose six fixed entries force a unique Latin-square completion.
The missing part of the original response was therefore not a short calculation but the complete classification of all $2767187500$ clue sets by the value of $N(P)$. The numerical answers must be taken from the exhaustive enumeration described above.