Welcome
to SudokuAssistant, designed to provide assistance when you’re
solving Sudokus and to provide you with Sudokus to solve. The assistance is at varying
levels, ranging from analysis of possibilities, through the provision
of hints, to the automatic solution of a Sudoku. It can help
you to understand how to solve a Sudoku if you’re inexperienced, or
just help you solve them more quickly if you’re more experienced.
Its
key features are:
- it
can analyse all the cells in a Sudoku and inform you which numbers are possible in the cells;
- it
can fill in all the cells that have only one possible number
based on this analysis, so saving you time and effort;
- it
can provide you with a clue - which cell to look at for your next move
- it
can provide you with a hint on what to do next - and then do it for you
if you request it to do so;
- it
keeps a record of what you’re doing, and lets you go back a step at a
time if you think you’ve made a mistake, or go right back to the
beginning;
- it can check and highlight errors;
- it
can solve the Sudoku for you automatically if you just want the
solution for some reason.
The
hints and the automatic solution can handle any 9x9 Sudoku that has a
solution, even those that require you to make guesses and backtrack if
the guesses prove wrong. It has a Set Mark and a Go back to
Mark feature that should prove useful if you’re trying to
solve such Sudokus unaided.
SudokuAssistant also has many built-in Sudokus for you to practise on.
How to solve a Sudoku
A
traditional Sudoku puzzle is built around a 9x9 grid with 81 cells.
This grid consists of 27 groups
- the 9 rows, the 9 columns and the 9 3x3 squares (shown shaded
in the grid below). 9 numbers, 1-9, must be placed on
the grid such that each number occurs once and once only in each group
(i.e. in each row, each column and each 3x3 square).
A
Sudoku puzzle has the symbols in some of the cells already defined, so
the puzzler must try to place the numbers 1-9 in the blank cells so that
they all satisfy the constraint of appearing exactly once in each group.
Technique 1 - Last unoccupied cell in a group
By far the easiest technique used in solving any Sudoku is looking for a group that has eight occupied cells. The value that must go in the only unoccupied cell is then obvious: the number from 1-9 that isn't already in the group.
For example, in the following partially-completed Sudoku, look at column 3. This has eight occupied cells, so that the only unoccupied cell (in row 4) must be a 3.
Technique 2 - Only cell in a square that can take a particular value
Technique 1 normally cannot be used when you start to solve a Sudoku. Instead, most solvers of Sudokus would start off by looking to see whether there is an easily identifiable cell that must take a certain value because it is the only one in a square that could take this value. This involves looking at the 3 rows and 3 columns that intersect with this square. For example, take a look at
the top-middle square of the Sudoku below.
This currently doesn't have a 1, so where could the 1 be placed in the top-middle square? It cannot go in the first column, as there's already a 1 in that column (in the square below). It cannot go in the second column, as there's already a 1 in that column further down (in the bottom-middle square). It must therefore go in the third column. Within that column, it cannot go in the third row as this already contains a 4. It cannot go in the second row as there's already a 1 in that row (in the top-left square). This means that the 1 MUST go in the top row of its third column, as there's nowhere else available.
Technique 3 - Only value a cell can take
With Technique 1, we looked for the last unoccupied cell in a group. This is a special, easy case of the situation where there is only one value that a cell can take. More generally, every cell is a member of a row, a column and a group. If we look at these and find that the row, column and group together contain eight different numbers, then this cell must contain the ninth.
For example, look at the cell at row 6, column 4, in the following partially-completed Sudoku:
Row 6 and column 4 together contain eight different numbers, meaning that this cell must contain the ninth number, i.e. 6.
Technique 4 - Only cell in a row or column that can take a particular value
This is very similar to Technique 2 but is generally harder to spot. Instead of looking at 3 rows and 3 columns, we need potentially to look at the 9 rows or columns that cross this one, and the three groups it crosses.
For example, look at row 1 in the following partially-completed Sudoku:
This must contain a 2. Now, there's a 2 in the top-left square already, so there cannot be a 2 in the first two empty cells of the row. The 4th cell cannot contain a 2 as there's already one in that column. Likewise, there are already 2s in columns 8 and 9, so these cells cannot take a 2. This leaves only cell 7 of the row that can take a 2.
Making use of analysis
Techniques 3 and 4 can be employed by simply looking at the Sudoku, but their use can be hard to spot. So, for many Sudokus, solvers may need at some point to carry out a simple analysis of remaining blank cells to see which
numbers are possible for it in order to satisfy the constraints.
Now,
each cell is a member of three groups: a row, a column and a square.
For example, the top-left cell is a member of the top row,
the leftmost column and the top-left square. Essentially, the
analysis involves checking the row, the column and the square
associated with the cell to see which of the 9 numbers do not already
exist in one of these, as these are the only numbers that could possibly be placed in the cell.
So, for the following Sudoku:
if we look at the top-left cell, we can see
that because the top row already contains 6 and 7, the leftmost column
contains 7, 5, 2 and 8 and the top-left square contains 6, 1, 7, 3, and
5, the only values that it could possibly contain are 4 or 9.
If
we continue this analysis, we can see that the cells of the top-left
square can be analysed to yield the following results, where defined
values are shown in large, black bold text, while possible values are shown in small, green italics, where 2489 means that the cell could contain only a 2, a 4, an 8, or a 9.
If
we focus on this top-left square, we can see an example of the easiest
step to take when solving a Sudoku, once you have carried out such an analysis: the cell in the second
row and the first column can take only a 4. This must
therefore be a 4, so a 4 can be entered into the cell. This is an example of Technique 3. A lone possibility would also result with Technique 1.
The
top-left square also contains an example of a step to take that is less
easy to spot from the analysis. The cell in the top row and second column can
take the values 2, 4, 8 or 9. However, if we look at the rest
of the cells in this square, we can see that this is the only cell that
can take an 8. This therefore means that this cell MUST
contain the 8, as the 8 must appear somewhere in this square. This is an example of Technique 2, but similar reasoning can be used for rows and columns to help spot examples of Technique 4.
Given
that we can then fix these two cells, we can quickly see that the cells
of the top-left square can be completed as follows:
An
analysis of the complete grid should then enable the solver to begin
filling in more of the values until it is complete.
Many Sudokus can be solved using only the four techniques already described, either with or without the help of detailed analysis.
However,
with more difficult Sudokus, these four techniques may not be enough and
other techniques may be required. For example,
suppose we reach a position where no values can be defined using these four techniques, but find that there is a
square (similarly, for a row or column) that contains the following defined values
and possible values:
Note
that there are two cells containing only the same two possible values:
3 and 9. Although we can’t at this stage determine which is
the 3 and which is the 9, we do know that these two cells between them
MUST contain the 3 and the 9 since neither can take any other value.
Given that, we know that the 3 and the 9 cannot appear in any
other cell of this group. We can therefore simplify some of
the other cells in the group by eliminating these possible values from
them. This results in the following situation:
In
this case, we can see that this leaves the central cell that has only one possible value, 4, so we can fix this, and then the analysis will show that the bottom-left cell must be a 6, so we can fix that:
This
is an example of the fifth technique that can be used:
Technique 5: Look
for 2 cells in a particular group that have exactly 2 possible values,
the same for each cell. If any other cells of the group have
any of these 2 values as possibilities, these values may be eliminated
as possibilities for those other cells. More generally, look for n cells in a
particular group
that have exactly n possible values, the same for each cell.
If any
other cells of the group have any of these n values as possibilities,
these values may be eliminated as possibilities for those other cells.
Another
technique that is available for helping you to solve a Sudoku can be
demonstrated if a situation is reached where a particular square (similarly, for a row or column)
contains the following defined values and possible values:
In
this case, note that there are two cells containing the same possible
values, 1 or 2, as well as other possible values, but that no other
cells have 1 or 2 as possible values. Similar to Technique 5,
we can say that therefore these two cells must between them contain the
values 1 and 2. This means that these two cells
cannot possibly take any other value, so the other values can be
eliminated as possibilities:
Having
simplified the possibilities in this way, we find that the cell in the
leftmost column and second row down (possible values 7 or 8) is now
the only one that can take a 7, so this must be 7.
This
is an example of the sixth technique that can be used:
Technique 6: Look
for 2 cells in a particular group that share the same 2 values as
possibilities and are the only ones in the group to have either of
these values as possibilities. If either of these 2
cells have any other values as possibilities, these can be eliminated.
More generally, look for n cells in a
particular group that share the same n values as possibilities and are
the only ones in the group to have any of these values as
possibilities. If any of these n cells have any other values
as
possibilities, these can be eliminated.
Most
Sudokus require solvers to use only these six techniques (and the
easiest ones require solvers to use only the first two).
However, some puzzles are created that can not be solved
using just these techniques. Now, more advanced logic can sometimes be
employed in such situations, but this will not be discussed here.
Instead, when a situation is reached
where none of the these six techniques can be applied, solvers can simply
select a cell that has a certain number of possibilities (preferably only two), guess which
one may be correct, then continue to see whether this results in a
valid solution or whether it results in an inconsistency that shows the
guess was wrong, in which case another guess must be made.
So,
the seventh technique that might be required is:
Technique 7: Select
any of the possible values for a cell and set the cell to be this
value. Continue trying to solve the puzzle. If this results
in an inconsistency, so showing that the value set was wrong,
go back and undo the value that was guessed and also any values set after
this guess was made as they are dependent on this invalid guess. Then
choose any other possible value not yet selected instead and see how
this goes.
Note:
some puzzle setters may force the solver to make guesses in more than
one place, so the guessing and backtracking can be very complex.