Saturday, November 18, 2017

Techniques to Solve this Sudoku Puzzle


I have a sudoku puzzle seen below that I am trying to solve. I know I can punch this into some sudoku solver and get the answer but I am looking for techniques I can use to solve this. Any advice?


Sudoku board



Answer



I'll just state some sudoku solving strategies in general, so not for the sudoku posted by you in particular. (NOTE: You probably know the first few, but I just state all of them for completeness.)




Probably the easiest one that everyone knows: When there is only one candidate available, you can simply fill it in. For example:


enter image description here


We can only fill in a 6 at the marked cell, since any of the other numbers would conflict.



Again, a pretty easy one that everyone knows: When there is only one place in a particular row, column or block for a specific number to go, we can just fill it in. For example:


enter image description here


Here there is only one place for the 2 to go, and that is the marked cell.



Now we go to some strategies to remove potential candidates for cells.


enter image description here



Here we know the 7 can't be on the same row as the 7 displayed, so it must be at either of the green marked cells. At the same time, we can dismiss the 7 as candidate from all the purple marked cells.



If a number only has two candidates for two cells in two different blocks AND both cells are in the same column or row, we can remove that number as candidate in all other columns or rows. For example:


enter image description here


Here the 3 can only be in one of the green marked cells. Since there are only two candidates per block, we can dismiss all the purple marked cells to contain a 3.


enter image description here


Same principle. We know the 2 has to be in two of the green marked cells. Because it can only be in the green cells in the two blocks, we can dismiss it as candidates in the purple cells of the third block.



If two cells in the same row, column or block have only the same two candidates, we can dismiss them from all the other cells in the same row, column or block.


enter image description here



Let's look at the green marked cells. Here we see a 2 and 3. Because in one of the two green cells we must have a 2, and in the other a 3 (or vice-versa), we know there can't be any 2s or 3s in the same column, so we can dismiss the 2s and 3s from the purple marked cells.


In addition. The same two green cells are also in the same block, so we can also dismiss the 2s and 3s from the yellow marked cells.


The same strategy can be used with three or even four cells.



Hidden Pair is pretty similar to Naked Pair, but instead of dismissing numbers from other cells, it dismisses other numbers from the paired cells themselves.


enter image description here


Look at the two green cells. They are both in the same row, and both have the numbers 3 and 5 as potential candidates, AND the other empty cells in the same row doesn't have the 3 and 5 as potential candidates. So we know the 3 and 5 have to be in the green cells. Because of that, we can dismiss all other candidates in the green cells, so only the 3s and 5s are left.



enter image description here


If we look at the green cells we see two rows each containing two possible candidate cells for the number 9. For both of these rows, the two possible cells are in the same column. If we put a 9 in the top-right green cell, we know the top-left and bottom-right green cells are dismissed and the other 9 has to be in the bottom-left green cell. Because of that, we can dismiss the 9 from all the purple cells since they are in the same column.




Now we get into pretty obscure strategies in my personal opinion. Swordfish states that three columns can each have two or three candidates for the given number, as long as they fall on three common rows (or column & row vice-versa of course). It's pretty similar to X-Wing, but with a three times three net, instead of a two times two net. For example:


enter image description here


If we look at the green cells we see that in the three columns they only have two possible candidates for the number 1. Because each of those columns must contain one 1, and they also share three of the same rows, it means we can eliminate the 1 from the purple marked cells.



enter image description here


Let's say we have the candidates distributed like above. We can dismiss Z from the marked cell because of the following rules:



  • If XY becomes number X, then XZ must be number Z, so * cannot be number Z

  • If XY becomes number Y, then YZ must be number Z, so * cannot be number Z



enter image description here


Same rule applies for the image above.


enter image description here


In the above image we can dismiss the 7s from the purple cells. Because:



  • If row4-column4 (containing 57) becomes 5,

    • then row4-column7 (containing 25) must be 2,

    • then row6-column8 (containing 27) must be 7 (because they are in the same block),


    • then the purple cells can't be 7 anymore.



  • If row4-column4 (containing 57) becomes 7,

    • then the purple cells can't be 7 anymore.




Both paths lead to the same conclusion, so we can dismiss 7 from the purple marked cells.




With colouring we look for chains, and based on that we can eliminate candidates. For example:


enter image description here



  • If row8-column3 (green cell containing 12) is a 1, the red marked cell cannot be 1.

  • If row8-column3 is not a 1,

    • then row4-column3 (orange cell containing 12) must be a 1,

    • then row5-column1 (green cell containing 19) can't be a 1 (because they are in the same block),

    • then row5-column4 (orange cell containing 17) must be a 1,


    • so the red marked cell cannot be a 1.




Because both chains come to the same conclusion, we can eliminate candidate 1 from the red marked cell.



This is a combination of Naked Pairs and Colouring.


enter image description here


Let's look at cell row2-column6:




  • If row2-column6 is a 1,

    • then row2-column8 must be a 2,

    • then row3-column7 must be a 1,

    • then row4-column7 must be a 2



  • If row2-column6 is a 2,

    • then row2-column must be a 1,


    • then row3-column7 must be a 2,

    • then row4-column7 must be a 1




Either way of the other, in case of both chains, there can't be any 1s or 2s in the purple marked cell, so we can dismiss those as candidates.


NOTE: There must be an even number of cells in the chain to dismiss. For example, if the chain would only be row2-column8 -> row3-column7 -> row4-column7, then if row2-column8 is a 1, so must row4-column7; and if row2-column8 is a 2, so must row4-column7. All we know is that both cells contain the same number, but we don't know which of the two, so we cannot dismiss the 1s and 2s from row5-column8.



Let's say we have the following cells:


enter image description here



The numbers displayed are the ONLY candidates. We can build a chain like this:



  • If row1-column1 is a 3,

    • then row1-column5 must be 7,

    • then row2-column6 must be 6,

    • then row2-column8 must be 8,

    • then row3-column9 must be 1





So, we know that either row1-column1 or row3-column9 must be a 1. Because of that, we can dismiss the 1s from the marked cells.


enter image description here



  • If row1-column2 is a 5,

    • then row6-column2 must be 4,

    • then row6-column8 must be 7,

    • then row6-column1 must be 1





So we know that either row1-column2 or row6-column1 must be a 1. Because of that, we can dismiss the 1s from the purple marked cells.



enter image description here



  • If row2-column1 is a 2,

    • then row1-column2 must be a 7




  • If row2-column1 is a 1,

    • then row5-column1 must be a 2,

    • then row6-column2 must be a 1,

    • then row6-column8 must be a 3,

    • then row1-column8 must be a 2,

    • then row1-column2 must be a 7





Both chains lead to the same conclusion: row1-column2 must be a 7, so we can fill it in.



If all hope fails, you can always just guess. Just store your current state somewhere, pick an empty cell (preferably one with only two possible candidates) and fill one in. Then continue with the strategies above and see if you can solve it completely. If you can, congrats. If you cannot, try the other one. (If you still can't solve it, guess another starting cell with two possible candidates and repeat.)




So, I hope these solving strategies will help you solve your sudoku.


Sorry all for the long post, but I wanted to include all strategies.


No comments:

Post a Comment

classical mechanics - Moment of a force about a given axis (Torque) - Scalar or vectorial?

I am studying Statics and saw that: The moment of a force about a given axis (or Torque) is defined by the equation: $M_X = (\vec r \times \...