Solving a SuDoku Puzzle - Step By Step
Before starting, visit this URL and download the sudoku puzzle; we'll solve it together! http://www.timesonline.co.uk/article/0,,18209-1739363,00.html
Above, several noders have provided nice examples on the rules of sudoku puzzles, as well as a few examples on how to fill in a square or two on a grid. This writeup serves to demonstrate how to solve, from beginning to end, a sudoku puzzle.
You see, my mother is a big fan of word and letter puzzles, such as crosswords. When I got into a big sudoku kick earlier this year, I attempted to show her how to solve one, yet she didn't really seem to understand what was to be done, or what techniques to use. The big reason is that her thought processes are generally less logical and more organic in nature.
My solution was to take a relatively simple example and show her step by step how to deduce additional squares, all the way to the end of the puzzle. She read through this a time or two and was then able to start solving the puzzles. Before long, she was nearly as skilled as I am at solving sudoku puzzles.
So, without further ado, here is the solution to a sudoku puzzle from beginning to finish. I have chosen to solve the "mild" difficulty puzzle from the August 18, 2005 edition of the London Times as an example. This puzzle is available at http://www.timesonline.co.uk/article/0,,18209-1739363,00.html; you are advised to print yourself out a copy, get out a pen, and solve along with me.
Su Doku: August 18, 2005
The London Times Online
No. 306 - Rating: Mild
-------------------------------------
| : 1 : 3 | : : | 4 : 8 : |
| : : | 4 : : 2 | : : |
| 9 : : 7 | : : | 2 : : 6 |
-------------------------------------
| 3 : : | : 2 : | : : 5 |
| : 2 : | 7 : : 1 | : 6 : |
| 8 : : | : 4 : | : : 3 |
-------------------------------------
| 4 : : 5 | : : | 6 : : 8 |
| : : | 1 : : 5 | : : |
| : 8 : 2 | : : | 5 : 3 : |
-------------------------------------
The first thing to look for when starting a sudoku puzzle are each set of three rows (the first, second, and third rows; the fourth, fifth, and sixth rows; and the seventh, eighth, and ninth rows) and each set of three columns (again, the first, second, and third columns; the fourth, fifth, and sixth columns; and the seventh, eighth, and ninth columns). What you're looking for are numbers that appear in two of the members of the set, but not the third.
Let's go through each set of rows and columns one at a time.
In the first set of rows:
2 appears in the second and third rows, but not in the first
4 appears in the first and second rows, but not in the third
2 is a potential candidate to put onto the grid. We can see above that a 2 already occurs in the second set of columns (more specifically, the second row of the sixth column) and the third set of columns (more specifically, third row, seventh column). I've bolded these above to make it more clear.
-------------------------------------
| : 1 : 3 | : : | 4 : 8 : |
| : : | 4 : : 2 | : : |
| 9 : : 7 | : : | 2 : : 6 |
-------------------------------------
Thus, a 2 cannot be placed in the second or third row, because there is already a 2 in that row, and also, a 2 cannot be placed in the second or third small square, because there is already a 2 in each of these small squares. Let's then X out all of the squares we cannot place a 2 in. Note: you would NOT actually X out all these squares if actually solving a puzzle. This is to help you visualize the eliminated squares.
-------------------------------------
| : 1 : 3 | X : X : X | 4 : 8 : X |
| X : X : X | 4 : X : 2 | X : X : X |
| 9 : X : 7 | X : X : X | 2 : X : 6 |
-------------------------------------
That leaves only a single possible square where a 2 could be placed in the first row, so we can add that to the grid.
-------------------------------------
| 2 : 1 : 3 | : : | 4 : 8 : |
| : : | 4 : : 2 | : : |
| 9 : : 7 | : : | 2 : : 6 |
-------------------------------------
Let's repeat the process with the 4 that appears in the first and second rows, but not in the third:
-------------------------------------
| 2 : 1 : 3 | : : | 4 : 8 : |
| : : | 4 : : 2 | : : |
| 9 : : 7 | : : | 2 : : 6 |
-------------------------------------
-------------------------------------
| 2 : 1 : 3 | X : X : X | 4 : 8 : X |
| X : X : X | 4 : X : 2 | X : X : X |
| 9 : : 7 | X : X : X | 2 : X : 6 |
-------------------------------------
-------------------------------------
| 2 : 1 : 3 | : : | 4 : 8 : |
| : : | 4 : : 2 | : : |
| 9 : 4 : 7 | : : | 2 : : 6 |
-------------------------------------
Much like when the 2 was placed, you can observe that there can't be a 4 in the first or second row, nor the second or third small square. This leaves only one place you can put the 4; the second square in the third row.
In the second set of rows:
3 appears in the fourth and sixth rows, but not in the fifth
2 appears in the fourth and fifth rows, but not in the sixth
Putting the 3 on the grid is as simple as before. Taking the middle three rows...
-------------------------------------
| 3 : : | : 2 : | : : 5 |
| : 2 : | 7 : : 1 | : 6 : |
| 8 : : | : 4 : | : : 3 |
-------------------------------------
-------------------------------------
| 3 : X : X | X : 2 : X | X : X : 5 |
| X : 2 : X | 7 : : 1 | X : 6 : X |
| 8 : X : X | X : 4 : X | X : X : 3 |
-------------------------------------
-------------------------------------
| 3 : : | : 2 : | : : 5 |
| : 2 : | 7 : 3 : 1 | : 6 : |
| 8 : : | : 4 : | : : 3 |
-------------------------------------
... we can easily place a 3 in the very center square. Now, let's try placing the 2...
-------------------------------------
| 3 : : | : 2 : | : : 5 |
| : 2 : | 7 : 3 : 1 | : 6 : |
| 8 : : | : 4 : | : : 3 |
-------------------------------------
-------------------------------------
| 3 : X : X | X : 2 : X | X : X : 5 |
| X : 2 : X | 7 : 3 : 1 | X : 6 : X |
| 8 : X : X | X : 4 : X | : : 3 |
-------------------------------------
Hmm... there are still two possible places that we could put the 2 in the sixth row. Can we get another clue? Let's look at that whole column, leaving the "imaginary" X's in place.
-------------
| 4 : 8 : |
| : : |
| 2 : : 6 |
-------------
| X : X : 5 |
| X : 6 : X |
| : : 3 | <-- we want to put a 2 in this row
-------------
| 6 : : 8 |
| : : |
| 5 : 3 : |
-------------
In the leftmost column, you'll see a number 2 in the third row above. Let's put Xs in the entire leftmost column as well:
-------------
| 4 : 8 : |
| X : : |
| 2 : : 6 |
-------------
| X : X : 5 |
| X : 6 : X |
| X : : 3 | <-- we want to put a 2 in this row
-------------
| 6 : : 8 |
| X : : |
| 5 : 3 : |
-------------
And we're left with only one possible square to put that 2 into!
In the third set of rows, there's nothing of note, so let's look at where we're at (solutions we've added are in bold):
-------------------------------------
| 2 : 1 : 3 | : : | 4 : 8 : |
| : : | 4 : : 2 | : : |
| 9 : 4 : 7 | : : | 2 : : 6 |
-------------------------------------
| 3 : : | : 2 : | : : 5 |
| : 2 : | 7 : 3 : 1 | : 6 : |
| 8 : : | : 4 : | : 2 : 3 |
-------------------------------------
| 4 : : 5 | : : | 6 : : 8 |
| : : | 1 : : 5 | : : |
| : 8 : 2 | : : | 5 : 3 : |
-------------------------------------
Let's try adding more numbers using the columns.
In the first set of columns:
4 appears in the first and second columns, but not in the third
3 appears in the first and third columns, but not in the second
Neither of these make it possible for us to add a number. With the 4, we know it has to go in the middle three squares of the third row. Since they're all empty and the only additional clue we can get is that it can't go into the bottom square in that row, we have to skip it. Here's a grid with Xs indicating squares where you can't put the 2 along with that little region in bold to help you visualize this.
-------------------------------------
| 2 : 1 : 3 | : : | 4 : 8 : |
| X : X : | 4 : : 2 | : : |
| 9 : 4 : 7 | : : | 2 : : 6 |
-------------------------------------
| 3 : X : | : 2 : | : : 5 |
| X : 2 : | 7 : 3 : 1 | : 6 : |
| 8 : X : X | X : 4 : X | X : 2 : 3 | <- no new 4 in this
------------------------------------- row because of
| 4 : X : 5 | : : | 6 : : 8 | the 4 in the 5th
| X : X : | 1 : : 5 | : : | column
| X : 8 : 2 | : : | 5 : 3 : |
-------------------------------------
^ ^
there can't be another 4 in this column
because of the 4 in the seventh row
|
|
there can't be another 4 in this column
because of the 4 in the third row
A similar problem occurs with the 3. We can only say that it goes in the second column in one of the bottom three squares, but that still leaves us with two possibilities and we can't reduce it any more than that.
In the second set of columns:
1 appears in the first and third columns, but not in the second
4 appears in the first and second columns, but not in the third
2 appears in the second and third columns, but not in the first
We can't put the 1 in for the same reason we couldn't put the 4 and the 3 in the first set of columns: there are two empty squares left that are possibilities. Can you see why? The possible squares are marked with a 0 below.
-------------------------------------
| 2 : 1 : 3 | : : | 4 : 8 : |
| : : | 4 : 0 : 2 | : : |
| 9 : 4 : 7 | : 0 : | 2 : : 6 |
-------------------------------------
| 3 : : | : 2 : | : : 5 |
| : 2 : | 7 : 3 : 1 | : 6 : |
| 8 : : | : 4 : | : 2 : 3 |
-------------------------------------
| 4 : : 5 | : : | 6 : : 8 |
| : : | 1 : : 5 | : : |
| : 8 : 2 | : : | 5 : 3 : |
-------------------------------------
With both the 4 and the 2, we have more success. First, the 4:
-------------
| X : X : X |
| 4 : X : 2 | <- there can only be
| X : X : X | one 4 in each
------------- small square
| X : 2 : X | |
| 7 : 3 : 1 | <--------/
| X : 4 : X |
-------------
| X : X : |
| 1 : X : 5 |
| X : X : |
-------------
^ ^
there can only be one 4 in each column
-------------------------------------
| 2 : 1 : 3 | X : X : X | 4 : 8 : |
| : : | 4 : X : 2 | : : |
| 9 : 4 : 7 | X : X : X | 2 : : 6 |
-------------------------------------
| 3 : : | X : 2 : X | : : 5 |
| : 2 : | 7 : 3 : 1 | : 6 : |
| 8 : : | X : 4 : X | : 2 : 3 |
-------------------------------------
| 4 : X : 5 | X : X : X | 6 : X : 8 | <- only one 4 in this row
| : : | 1 : X : 5 | : : |
| : 8 : 2 | X : X : 4 | 5 : 3 : |
-------------------------------------
As you see, we can thus place a 4 in the bottom row of the sixth column. How about the 2?
-------------
| X : X : X |
| 4 : X : 2 |
| X : X : X |
-------------
| X : 2 : X |
| 7 : 3 : 1 |
| X : 4 : X |
-------------
| : X : X |
| 1 : X : 5 |
| : X : 4 |
-------------
-------------------------------------
| 2 : 1 : 3 | : X : X | 4 : 8 : |
| : : | 4 : X : 2 | : : |
| 9 : 4 : 7 | : X : X | 2 : : 6 |
-------------------------------------
| 3 : : | : 2 : X | : : 5 |
| : 2 : | 7 : 3 : 1 | : 6 : |
| 8 : : | : 4 : X | : 2 : 3 |
-------------------------------------
| 4 : : 5 | 2 : X : X | 6 : : 8 |
| : : | 1 : X : 5 | : : |
| X : 8 : 2 | X : X : 4 | 5 : 3 : X |
-------------------------------------
And we can put the 2 into the seventh row of the fourth column.
In the third set of columns:
2 appears in the first and second column, but not the |