sudoku solving techniques

22
Sudoku Solving Techniques One of the greatest aspects of Sudoku is that the game offers engaging challenges to both the novice, as well as the seasoned puzzle player. Whenever they play a puzzle tailored for their level of competence, both the beginner and the experienced Sudoku solver will have to put a good amount of thought and technique into completing the task. Their approach, though, may not be the same. Solving a hard Sudoku puzzle will require quite a different set of techniques than an easy one. This article presents nine such techniques; in increasing difficulty. When utilizing these techniques, the way the pros prefer to do it, is to start with the basic ones. Use the first few techniques to insert as many numbers as you can. Then, when you can add no more numbers to the board using the basic techniques, try the more advanced ones. Do one at a time until you can plot one more number into a cell. Then, start with the basic techniques again, and repeat the process. You should be able to solve almost any Sudoku puzzle using these techniques. Techniques for removing numbers: Sole Candidate When a specific cell can only contain a single number, that number is a "sole candidate". This happens whenever all other numbers but the candidate number exists in either the current block, column or row. In this example, the red cell can only contain the number 5, as the other eight numbers have all been used in the related block, column and row.

Upload: danny-velarde

Post on 17-Nov-2015

5 views

Category:

Documents


0 download

DESCRIPTION

Easy Techniques in solving Sudoku puzzle

TRANSCRIPT

Sudoku Solving Techniques

One of the greatest aspects of Sudoku is that the game offers engaging challenges to both the novice, as well as the seasoned puzzle player. Whenever they play a puzzle tailored for their level of competence, both the beginner and the experienced Sudoku solver will have to put a good amount of thought and technique into completing the task. Their approach, though, may not be the same. Solving a hard Sudoku puzzle will require quite a different set of techniques than an easy one. This article presents nine such techniques; in increasing difficulty.

When utilizing these techniques, the way the pros prefer to do it, is to start with the basic ones. Use the first few techniques to insert as many numbers as you can. Then, when you can add no more numbers to the board using the basic techniques, try the more advanced ones. Do one at a time until you can plot one more number into a cell. Then, start with the basic techniques again, and repeat the process. You should be able to solve almost any Sudoku puzzle using these techniques.

Techniques for removing numbers:

Sole Candidate

When a specific cell can only contain a single number, that number is a "sole candidate". This happens whenever all other numbers but the candidate number exists in either the current block, column or row. In this example, the red cell can only contain the number 5, as the other eight numbers have all been used in the related block, column and row.

Unique Candidate

You know that each block, row and column on a Sudoku board must contain every number between 1 and 9. Therefore, if a number, say 4, can only be put in a single cell within a block/column/row, then that number is guaranteed to fit there. This example illustrates the number 4 as the unique candidate for the cell marked in red.

Techniques for removing candidates:

Block and column / Row Interaction

This method won't help you pencil in any new numbers, but it will help you nail a number down within a specific row or column. The example shows that the number 7 can only be inserted in the red cells of the middle row. Thus you can remove 7 as a possible candidate from the rest of the row.

Block / Block Interaction

This technique is best understood by looking at the example. In the middle and the middle-right blocks, the number 8 must be placed in one of the red cells. This means, we can eliminate 8 from the upper and lower rows in the middle-right column.

Naked Subset

The example shows that row number 1 and row number 5 both have a cell in the same column containing only the candidate numbers 4 and 7. These two numbers appear as candidates in all of the other open cells in that column too, but since they are the only two candidates in rows 1 and 5, these two numbers cannot appear anywhere else in the row, thus you can remove them. In the example, the two candidate pairs circled in red, are the sole candidates. Since 4 and 7 must be placed in either of these two cells, all of the pairs circled in blue, can remove those numbers as candidates. In this puzzle, this means 1 becomes sole candidate in the second row; 2 becomes sole candidate in row 6; and thus, 2 is sole candidate for row number 4.

You can also use this technique if you have more than two candidates. For example, let us say the pairs circled in red were instead triple candidates of the numbers 1, 4, 7. This would mean those three numbers would have to be placed in either rows 1, 2 or 5. We could remove these three numbers as candidates in any of the remaining cells in the column. This technique even works with four candidate numbers, assuming you have 4 possible candidates in four different cells in a row/column.

Hidden subset

This is similar to Naked subset, but it affects the cells holding the candidates. In this example, we see that the numbers 5, 6, 7 can only be placed in cells 5 or 6 in the first column (marked in a red circle), and that the number 5 can only be inserted in cell number 8. Since 6 and 7 must be placed in one of the cells with a red circle, it follows that the number 5 has to be placed in cell number 8, and thus we can remove any other candidates for this cell; in this case, 2 and 3.

X-Wing

This method can work when you look at cells compromising a rectangle, such as the cells marked in red. In this example, let's say that the red and blue cells all have the number 5 as candidate numbers. Now, imagine if the red cells are the only cells in column 2 and 8 in which you can put 5.

In this case you obviously need to put a 5 in two of the red cells, and you also know they cannot both be in the same row. Well, now, this means you can eliminate 5 as the candidate for all the blue cells. This is because in the top row, either the first or the second red cell must have a 5, and the same can be said about the lower row.

Swordfish

Swordfish is a more complicated version of X-Wing. In most cases, the technique might seem like much work for very little pay, but some puzzles can only be solved with it. So if you want to be a sudoku-solving master, read on! Example A

In example A, we've plotted in some candidate cells for the number 3. Now, assume that in column 2, 4, 6 and 8, the only cells that can contain the number 3 are the ones marked in red. You know that each column must contain a 3. Example B

I will give you the punch-line before the joke now; look at example B. We can eliminate 3 as candidate in every cell marked in blue. The reason for this is that if we consider the possible placements of the number 3 in the red cells, we get two alternatives: either you must put 3s in the green cells, or in the purple cells, as example C shows. In any case, each of the rows 2, 4, 6 and 8, must contain a 3 in one of the colored cells, so no other cell in those rows can contain a 3. Example C

How do you recognize a swordfish pattern? You look for cells with common candidate numbers that can be chained together like in example D. If you start on, say, the top-left red cell. Then you draw a line either vertically or horizontally until you reach another cell containing the same candidate number. Then you repeat this pattern until you return to the original cell. If you reach the original cell, you have a swordfish pattern! Example D

Forcing Chain

Forcing chain can actually help you determine exactly what number a certain cell must hold. Unfortunately, the technique is not the easiest to utilize. Look at the example. Let us assume that the candidates in the red cells are the sole candidates for those cells.

Forcing chains work in the following way: Start on the red cell with the arrow pointing towards it, and fill in one of the two candidates, 3 or 6, for that cell. Then follow on and fill in the rest of the red cells. Now take a note of the values you enter along the way. Go back to the cell you started with and try the other candidate number for that cell, and fill in the other red cells as well. Compare the numbers you got now with the first result. You may find that in both cases, a certain cell must contain a specific number.

In this example, if you put the number 3 in the starting cell, you will see that the above-right neighboring cell must contain a 9. Now, try and enter a 6 in the starting cell instead, and move the other way around, entering candidate values. When you reach the above-right neighboring cell again, you will find it must contain a 9 this time around too. Thus this cell must contain a 9.

SuDoKu-CrackerNaked Pairs

If two cells in a group (row, column or 3x3 box) contain an identical pair of candidates and only those two candidates, then no other cells in that group could be those values. These to candidates can be excluded from other cells in the group.

In the example above, the candidates 4 & 7 in columns three and seven form a Naked Pair within the row. Therefore, since one of these cells must be the 4 and the other must be the 7, candidates 4 & 7 can be excluded from all other cells in the row.

SuDoKu-CrackerHidden Pairs

If two cells in a group (row, column or 3x3 box) contain an identical pair of candidates and no other cells in that group contain those 2 candidates, then other candidates in those two cells can be excluded safely.

In the example above, the candidates 2 & 5 are only located in two highlighted cells of the row, and therefore form a pair. All candidates except 2 & 5 can safely be excluded from these two cells as one cell must be the 2 while the other must be the 5.

SuDoKu-CrackerLocked Candidates

Sometimes a candidate within a box is restricted to one row or column. Since one of these cells must contain that specific candidate, the candidate can safely be excluded from the remaining cells in that row or column outside of the box. In the example above, the middle box only has candidate 2's in its middle row. Since, one of those cells must be a 2, no cells in that row outside that box can be a 2. Therefore 2 can be excluded as a candidate from the highlighted (yellow) cells.

Sometimes a candidate within a row or column is restricted to one box. Since one of these cells must contain that specific candidate, the candidate can safely be excluded from the remaining cells in the box. In the example above, the left column has candidate 3's only in the upper box. Therefore, since one of these cells must be a 3 (otherwise the column would be without a 3), 3's can safely be excluded from all cells in this box except those in the left column.

SuDoKu-CrackerX-Wing

We are looking for two rows (or columns) that contain exactly two of a particular number.

In the example above, a x-wing is formed by the columns one and nine wiht the candidate 4. Therefore, other candidate 4's in row three and six (highlighted yellow) can safely be removed.

SuDoKu-CrackerSwordfish

We are looking for three rows (or columns) that contain up to three of a particular number in the same relative position. Although Swordfish are an extension of X-Wing.

In the example above, each of the three rows (two, six & eight) have candidate 5 in no more than three cells which share the same three columns (five, seven & nine). A Swordfish pattern is established. Other candidate 5's in these three columns (highlighted yellow) can be excluded safely.

SuDoKu-CrackerJellyfish

We are looking for four rows (or columns) that contain up to four of a particular number in the same relative position. Although Jellyfish are an extension of Swordfish ( X-Wing ).

In the example above, each of the four rows (two, tree, six & seven) have candidate 1 in no more than four cells which share the same for columns (one, four, six & seven). A Jellyfish pattern is established. Other candidate 1's in these four columns (highlighted yellow) can be excluded safely.

SuDoKu-CrackerNaked Triples

The same principle that applies to Naked Pairs applies to Naked Triples and Naked Quads.

A Naked Triple occurs when three cells in a group (row, column or 3x3 box) contain no candidates other than the same three candidates. The cells which make up a Naked Triple don't have to contain every candidate of the triple. If these candidates are found in other cells in the group they can be excluded.

In the example above, a Naked Triple is formed by the left middle, middle bottom & right middle cells of a 3x3 box since they only contain the candidates 2, 5 & 7. Therefore the candidates 7 in the highlighted (yellow) cells can be excluded safely.

SuDoKu-CrackerHidden Triples

The same principle that applies to Hidden Pairs applies to Hidden Triples and Hidden Quads.

A Hidden Triple occurs when three candidates are only in three cells in a group (row, column or 3x3 box). Wenn no other cells in that group contain those 3 candidates, other candidates in those three cells can be excluded safely.

In the example above, the candidates 2, 4 & 5 are only located in the tree highlighted cells of the 3x3 box, and therefore form a Triple. All other candidates (except 2, 4 & 5) can safely be excluded from those three cells.

SuDoKu-CrackerXY-Wing

We are looking for three cells in two groups (row, column or 3x3 box) that each contain exactly two candidates and they shares the same three candidates.

In the example above, a xy-wing is formed by the cells R2C2, R2C5 and R8C5. (R2C2 and R2C5 are in the same row, and R2C5 and R8C5 are in the same column.)Since either R2C2 or R8C5 must contain 2, candidate 2 in R8C2 (highlighted yellow) can safely be removed.

SuDoKu-CrackerColors

If one candidate is only in two cells in a group (row, column or 3x3 box), we call it a conjugate pair.In the example above, the candidates 8 are in Row 2, only located in Column 3 & 9. This two (R2C3 & R2C9) are a conjugate pair. One of those two has to be false (cannot be 8) and the other has to be true (must be 8). We mark them with two different colors. R2C9 builds another conjugate pair with R1C7, and R1C7 with R7C7. We now know that either R2C3 or R7C7 has to be true (different colors). Therefore the candidates 8 in the highlighted (yellow) cells can safely be excluded from this cell.

In the example above, we start with R5C1 and look for candidates 9 which has a conjugate relationship to R5C8, R8C1 and R6C2 . By filling the grid, we see that both R5C8 and R6C9 (which are in the same box) has the same color. Since every 3x3 box can only have one 9, this color must be the false value. The candidates 9 can be removed from all cells with this color.

SuDoKu-CrackerMultiple Colors

If one candidate is only in two cells in a group (row, column or 3x3 box), we call it a conjugate pairs.In the example above, the candidates 3 are in Column 2, only located in Row 3 & 7. This two (R3C2 & R7C2) are a conjugate pairs. One of those two has to be false and the other has to be true. We mark them with two different colors.R3C7 builds another conjugate pairs with R8C7, and R8C7 to R8C1. Both R3C7 and R8C1 has to be true or false.We now know that either R3C2 or R7C2 has to be true. Therefore R3C7 and R8C1 cannot both be true, they has to be false, and the candidates 3 in this two highlighted (yellow) cells can safely be excluded.