A Pencil-and-Paper Algorithm For Solving Sudoku Puzzles: (Reduced From Paper by JF Crook)
A Pencil-and-Paper Algorithm For Solving Sudoku Puzzles: (Reduced From Paper by JF Crook)
Preemptive Sets 7 6
A preemptive set, X, is a subset of S with a cardinality m, 2 ≤ m 3459 459
≤ 9, that appear across m cells (which we’ll call the span of X),
such that only elements of X appear in the markup of those 8 1
cells. The range of a preemptive set is the row, column or box 23478 34
in which all the cells of the preemptive set are located. In the
3x3 box to the right, there is a preemptive set of m = 4 9
containing [3,4,5,9] that spans [c(7,1), c(7,2), c(8,3), c(9,3)]. 234579 24579 345
Occupancy Theorem
The numbers in the preemptive set, X, cannot appear elsewhere in the range of X, only in the specific m
cells that X spans. A quick proof: Consider, for contradiction that a number in X appears elsewhere in
Qarghah, Mohammad Edris
Math 490 – Graph Theory
the range of X. Then it could not appear in the m cells, meaning there would be m – 1 elements to fill m
cells, which would result in a blank space, which violates the conditions for a Sudoku solution.
1 2 3
Hidden Sets
As occupancy theorem means we can safely remove the 7 6
elements of a preemptive set, X, from the range of X (in this 3459 459
case the box) outside the span of X (the four cells containing
[3,4,5,9] exclusively), we reveal hidden preemptive sets or 8 8 1
singletons. In this example, the removal of [3,4,5,9] from other 23478 34
sets is indicated by a strikethrough. This can, in turn, be used
9
to find further preemptive sets (note [2,7] in [c(9,1), c(9,2)],
234579 24579 345
which have been bolded and underlined) and singletons (the
preemptive set [2,7] is additionally removed revealing the singleton 8) until either a solution is reached
or no preemptive sets can be broken down into smaller preemptive sets.
Random Choice
When no preemptive sets can be broken down into smaller preemptive sets, then we are forced to
make a random choice and generate a search path “on the fly.” Given the current markups, randomly
assign an available number to a cell (creating a vertex) and then proceed (in a different color) to
evaluate the subsequently available preemptive sets. This will lead to either a solution (in which case
you’re done), another group of preemptive sets that can’t be broken down (in which case you proceed
with a random choice, creating a new vertex and search path in a different color), or a Sudoku violation.
Vertex Coloring
Sudoku is essentially a very complicated vertex coloring problem. Each cell of the Sudoku puzzle
corresponds to a vertex which is adjacent to every other vertex in its column, row and box. There are
nine available colors (the numbers one through nine) with which we are trying to give the graph a
proper coloring and the act of “marking up” the grid is identifying the potential colorings of each
individual vertex, given its adjacent vertices.
Our initial markup of the cells, indicate what colors each vertex can be paired with. In the case of
preemptive sets in the example used above, four of the vertices are neighboring only the same four
elements of S. As we are seeking a perfect matching, it doesn’t matter what other neighbors those
elements of S might have in A, as they need to be matched to those four vertices. What this means is
that we can break the bipartite graph into two separate bipartite graphs, which might in turn, via similar
logic, be broken down even further, perhaps even resulting in a single perfect matching (as with c(8,1),
which we’ll call a4 and 8).
After we have broken apart these bipartite graphs as far as they will go, however, they, by definition, are
no longer interrelated and, as such, cannot inform each other’s perfect matching directly. However,
each element of box A correlates to a column and a row, which also must be perfectly matched. As such,
a4 might be the same as b1 (both represent c(8,1)) in set B (corresponding to row 8), which, now set to 8,
informs the breakdown of its bipartite graph into a perfect matching. The breakdown of B in turn
informs columns and other boxes.