Skip to content →

Tag: sudoku

bivalue Sudoku graphs

Here is
a ‘difficult but not unsolvable’ Sudoku from David Eppstein‘s paper Nonrepetitive paths and cycles
in graphs with application to Sudoku
.

$\begin{sudoku-block} |5| | | | |1| | |8|. | | | | | | |6| | |.
| | | | |6|2|5|7| |. | |9| |2| |5|1| | |. | | |4| |1| |3| | |. | |
|8|3| |9| |2| |. | |7|6|9|8| | | | |. | | |5| | | | | | |. |8| | |1|
| | | |3|. \end{sudoku-block}y1 $

As always I try to solve
Sudokus without having to use backtracking (that
is, making a guess and working from there on to a solution or a
contradiction in which case one uses the other option). Clearly, this is
not well defined. When one starts solving Sudokus one often resorts to
backtracking but after a while one discovers rules which seem to avoid
backtracking (but in a sense are still). For example, if two cells in a
same block (or row or column) can only be filled with two numbers one
can use this fact by forbidding other numbers to occupy those cells.
However, this is a mini-backtracking strategy. Still, I allow all such
rules. More precisely, any formal rule is non-backtracking in my
dictionary. In Eppstein’s paper there is a good summary of the rules
most people apply when starting a Sudoku. He calls them the ‘local
rules’. Here they are

  • If a digit x has only one remaining
    cell that it can be placed in, within some row, column, or square, then
    we place it in that cell. Any potential positions of x incompatible with
    that cell (because they lie in the same row, column, or square) are
    removed from future consideration.
  • If a cell has only one
    digit x that can be placed in it, we place x in that cell. Incompatible
    positions for x are removed from future consideration.
  • If
    some three cells, formed by intersecting a row or column with a square,
    have three digits whose only remaining positions within that row,
    column, or square are among those three cells, we prevent all other
    digits from being placed there. We also remove positions for those three
    forced digits outside the triple but within the row, column, or square
    containing it.
  • If the cells of a square that can contain a
    digit x all lie in a single row or column, we eliminate positions for x
    that are outside the square but inside that row or column. Similarly, if
    the cells that can contain x within a row or column all lie in a single
    square, we eliminate positions that are inside that square but outside
    the row or column.
  • If two digits x and y each share the same
    two cells as the only locations they may be placed within some row,
    column, or square, then all other digits must avoid those two cells.
  • If the placement of digit x in cell y can not be extended to a
    placement of nine copies of x covering each row and column of the grid
    exactly once, we eliminate cell y from consideration as a placement for
    x.
  • If the placement of a digit x in cell y within a single
    row, column, or square can not be extended to a complete solution of
    that row, column, or square, then we eliminate that placement from
    consideration.

But even if one manages to use all
these rules (and frankly I only use a subset) one might get stuck. I
don’t know how many cells you can fill in the above problem with these
local rules, I’m afraid I only managed $5 $… At such
moments, the bivalue Sudoku-graph may come in handy. Eppstein defines
this as follows

In this graph, we create a vertex
for each cell of the Sudoku grid that has not yet been filled in but for
which we have restricted the set of digits that can fill it to exactly
two digits. We connect two such vertices by an edge when the
corresponding two cells both lie in a single row, column, or square, and
can both be filled by the same digit; the label of the edge is the
digit they can both be filled by.

Eppstein then goes
on to define new rules (each of which is a mini-backtracking strategy)
which often help to crack the puzzle. Here are Eppstein’s ‘global
rules’

  • If an edge in the bivalue graph belongs to a
    nonrepetitive cycle, the digit labeling it must be placed at one of its
    two endpoints, and can be ruled out as a potential value for any other
    cell in the row, column, or square containing the edge.
  • If
    the bivalue graph has a cycle in which a single pair of consecutive
    edges has a repeated label, that label can not be placed at the cell
    shared by the two edges, so that cell must be filled by the other of its
    two possible values.
  • If the bivalue graph contains two
    paths, both starting with the same label from the same cell, both
    ending at cells in the same row, column, or square, and such that in the
    two ending squares the values not occurring on the incident edge labels
    are equal, then the cell at the start of the paths can not be filled by
    the start label of the paths, and must be filled by the other of its two
    possible values.

For example, in the above problem it
is not hard to verify that the indicated places X,Y and Z form a
nonrepetitive cycle in the bivalue graph so applying the first global
rule we have two choices of filling these places (one leading to a
solution, the other to a contradiction)

$\begin{sudoku-block} |5| | | | |1| | |8|. | | | | | | |6| | |.
| | | | |6|2|5|7| |. | |9| |2| |5|1| | |. | | |4| |1| |3| | |.
|X|Y|8|3| |9| |2|Z|. | |7|6|9|8| | | | |. | | |5| | | | | | |. |8| |
|1| | | | |3|. \end{sudoku-block}y2 $

In fact, it turns out
that making this choice is enough to solve the puzzle by simple local
rules. So, if I change the original puzzle by filling in the cell X

$\begin{sudoku-block} |5| | | | |1| | |8|. | | | | | | |6| | |.
| | | | |6|2|5|7| |. | |9| |2| |5|1| | |. | | |4| |1| |3| | |. |6|
|8|3| |9| |2| |. | |7|6|9|8| | | | |. | | |5| | | | | | |. |8| | |1|
| | | |3|. \end{sudoku-block}y3 $

you will have no problem
solving the puzzle.

Leave a Comment

hints for micro-sudoku

As a
quick reply to last posts comment :

Another
interesting question: How many clues (numbers allready in the grid) do
we need a Sudoku puzzle to have in the beginning in order to obtain a
unique solution? Comment by A.R.Ray

At
least one student proved that in micro-Sudoku (on a 4×4 grid)
one needs just 4 hints to get any unique solution (and that 4 is
minimal). It is an application of the fact that the micro-Sudoku group
acts on the set of all solutions with just two orbits so one needs to
check just these two solutions…

Leave a Comment

micro-sudoku

One
cannot fight fashion… Following ones own research interest is a
pretty frustrating activity. Not only does it take forever to get a
paper refereed but then you have to motivate why you do these things
and what their relevance is to other subjects. On the other hand,
following fashion seems to be motivation enough for most…
Sadly, the same begins to apply to teaching. In my Geometry 101 course I
have to give an introduction to graphs&groups&geometry. So,
rather than giving a standard intro to graph-theory I thought it would
be more fun to solve all sorts of classical graph-problems (Konigsberger
bridges
, Instant
Insanity
, Gas-
water-electricity
, and so on…) Sure, these first year
students are (still) very polite, but I get the distinct feeling that
they think “Why on earth should we be interested in these old
problems when there are much more exciting subjects such as fractals,
cryptography or string theory?” Besides, already on the first day
they made it pretty clear that the only puzzle they are interested in is
Sudoku.
Next week I’ll have to introduce groups and I was planning to do
this via the Rubik
cube
but I’ve learned my lesson. Instead, I’ll introduce
symmetry by considering micro-
sudoku
that is the baby 4×4 version of the regular 9×9
Sudoku. The first thing I’ll do is work out the number of
different solutions to micro-Sudoku. Remember that in regular Sudoku
this number is 6,670,903,752,021,072,936,960 (by a computer search
performed by Bertram
Felgenhauer
). For micro-Sudoku there is an interesting
(but ratther confused) thread on the
Sudoku forum
and after a lot of guess-work the consensus seems to be
that there are precisely 288 distinct solutions to micro-Sudoku. In
fact, this is easy to see and uses symmetry. The symmetric group $S_4$
acts on the set of all solutions by permuting the four numbers, so one
may assume that a solution is in the form where the upper-left 2×2
block is 12 and 34 and the lower right 2×2 block consists of the
rows ab and cd. One quickly sees that either this leeds to a
unique solution or so does the situation with the roles of b and c
changed. So in all there are $4! \\times \\frac{1}{2} 4!=24 \\times 12 =
288$ distinct solutions. Next, one can ask for the number of
_essentially_ different solutions. That is, consider the action
of the _Sudoku-symmetry group_ (including things such as
permuting rows and columns, reflections and rotations of the grid). In
normal 9×9 Sudoku this number was computed by Ed Russell
and Frazer Jarvis
to be 5,472,730,538 (again,heavily using the
computer). For micro-Sudoku the answer is that there are just 2
essentially different solutions and there is a short nice argument,
given by ‘Nick70′ at the end of the above mentioned thread. Looking a bit closer one verifies easily that the
two Sudoku-group orbits have different sizes. One contains 96 solutions,
the other 192 solutions. It will be interesting to find out how these
calculations will be received in class next week…

Leave a Comment