Solving Sudoku Using Excel

July 31, 2017 | Author: Shaswat Rai | Category: Microsoft Excel, Spreadsheet, Hyperlink, Software, Computing
Share Embed Donate

Short Description

Solving Sudoku Using Excel...


Solving SUDOKU Using Excel Clyde Key Smashwords Edition Copyright 2012 Clyde Key

Solving SUDOKU Using Excel SUDOKU puzzles have become quite popular. Solving the puzzles is fun and is also good mental exercise. However many people just don’t ever try them, or they give up easily if they do. One reason is that it’s hard to keep track of all the number possibilities, particularly for the more difficult puzzles. It frustrates me when I get lost trying to solve a puzzle because I can’t read the numbers I’ve jotted on the sides and in the small spaces. Using a spreadsheet eliminates my problems with legibility. SolvingSUDOKU.xls is not a program that works the puzzles for you. However, this spreadsheet will help you keep track of number possibilities and allow you to see patterns that will help you to solve the puzzles. And you will begin to recognize patterns and develop techniques so you can solve SUDOKU puzzles without any extra helps. (You will likely soon become proficient enough that you won’t use your computer for most puzzles.) Since you’re using your computer to fill in the blanks, your entries are completely legible. In addition, the spreadsheet checks that the answers you enter are correct. You don’t have to wait for tomorrow’s newspaper to see if you have solved a puzzle correctly. Note: Your computer must have Microsoft Excel installed to use this spreadsheet.

1. The first step is to download the spreadsheet from the link in paragraph 8. I suggest saving the spreadsheet in a new folder named SolvingSudoku or whatever you wish to name it. Then it would be wise to make a subfolder in your folder and save a second copy there in case you accidentally modify or erase the original. Then open SolvingSudoku.xls and click file/save as and save the file in your new folder with an appropriate name—so that you can keep track of it. At minimum, I suggest including the date in the filename, such as sudoku_12_25_11, or whatever will be convenient for you.

2. Enter the digits from the puzzle you wish to solve in the appropriate cells. For this exercise, you can enter the digits that are used in the sample as follows:

Notice that the cells under each column and after each row of the grid contain the sums of the digits in the columns and rows. The cells under L, M. and N (not shown here) contain the sums of the digits in the nine sections of the grid. These are used to check whether the puzzle has been solved correctly when you are finished.

3. In each blank cell of the grid, enter an apostrophe (‘) followed by all of the digits 1-9 that are not contained in the column, row, or grid section where the cell is located. Except that the apostrophes will not be seen, the sample puzzle will look like this:

4. Look at each column, row, and section and see if there are any cells that contain only a single digit. In this example, cell D8 contains only the digit 9. So select the cell and enter 9 (without the apostrophe this time). Now look at each column, row, and section and see if any digits are contained only once. In the example, cell F2 contains the only 4 in its row and section, so enter the digit 4 without the apostrophe. Cell B5 contains the only digit 6 in the section, so enter the digit 6 in that cell. Cell I4 contains the only digit 3 in the row and section, so enter the digit 3 in that cell. Cell H9 contains the only digit 1 in that row, so enter the digit 1 in cell H9. Cell E8 contains the only digit 1 in that section, so enter 1 in cell E8. Cell H8 contains the only digit 7 in its row and section, so enter 7 in H8. Your sample puzzle will look like this:

Since you now have determined the digits that go into those five cells, you can delete those digits in the other cells of the same column, row or section. For instance, you can delete the digit 4 from cell F9. Then you can delete the digit 6 from cells D5 and F5, and the digit 3 from cells I2, I3, I7, and I8. Delete the digit 1 from cells H3, H8, and I8. Delete the digit 7 from cells H5 and H6. Delete the digit 4 from cells D7, F9, and G9. Then your sample will look like this:

Now you can go back to the beginning of step 4 and repeat the process. You see that by eliminating some possible digits, you have identified more cells that are positively proven. B9=9; D8=9; D9=4; and G6=7, so enter those digits. Then you can delete those digits from the other cells in the same column, row, or section. Your sample will look like this:

5. You can continue to solve the puzzle by repeating the instructions in step 4, but there is another combination that will help you to eliminate wrong digits. Whenever there is a pair of cells in a column, row, or section that contain only the same two digits, they are the only possible locations for those digits so that will allow you to eliminate them in the other cells of the column, row, or section. For instance, cells A5 and A6 contain the digits 5 and 8, so you can eliminate all the other digits 5 and 8 in that column and section. Row 5 also contains only the digits 5 and 8 in A5 and H5, so you can eliminate those digits in the other cells of row 5. And column F contains only the digits 2 and 3 in F1 and F9, allowing you to eliminate the digits 2 and 3 from the other cells in that column. Then you can continue to repeat the instructions in step 4 until the puzzle is solved. So that you can check your work, the complete solved puzzle is here:

6. A way to check your work: The cell at the bottom of each column and at the end of each row contains the sum of digits in the column or row. In addition, the cells under L, M, and N contain the sums of the digits in the sections that correspond to each. If the puzzle is solved correctly, the cells will always contain 45 since the sum of digits 1 through 9 is 45.

7. Oops! What if I come to a dead end and I still can’t solve the puzzle? Occasionally, when working with a very difficult puzzle, you may reach a dead end. You have eliminated all the digits you can, and you can’t see any more. Don’t despair because there are still ways you can attack the problem. There are a couple of approaches to take in solving the problem. But first you need to make a copy of your puzzle to work with, like this: (a) Right click on the Sheet 1 tab at the bottom of the screen. (b) Click on Move or Copy. (c) Click Create a Copy and OK. Now, on the copy, select a cell that has only two possible digits. You have an even chance of picking the right answer, so continue to solve the puzzle by eliminating digits. If you picked the right digit, you can solve the puzzle. But if reach the point where the puzzle is obviously wrong —such as finding two of the same digit in a column, row, or section—then you must go back to the original puzzle and continue with the other digit in that cell. The other way is to pick a cell with only two choices and think ahead to determine which is the right answer in that cell. That’s very difficult, but it’s good exercise even if you wind up using the first technique. I should note that most of the time when we believe we’ve reached a dead end, we really haven’t but have just failed to see all the possibilities. This technique will still work to help solve the puzzle. For example, this is a puzzle that seems to have come to a dead end at this point:

If we select the digit 4 for cell B1, we can work out most of the cells before we see that row 7 contains the digit 3 in two different cells. Therefore, the digit 4 is the wrong answer for cell B1.

So we will try again with the digit 7 in cell B1:

Now all of the rows, columns, and sections add up to 45 so we can see that the puzzle is solved correctly. You should note that even though some puzzle writers insist that there is only one possible correct answer to each puzzle, this is not always right. There are some patterns of digits that will allow more than one solution that will work. Don’t worry about it if your solution doesn’t match the published solution as long as all of your rows, columns, and sections add up to 45.

8. Downloading: Click here to download SolvingSudoku.xls. When the window opens on your browser, click on File and then click on Download. If you have downloaded the rtf or pdf version and the hyperlink does not work well, you can copy and paste this link in your browser address window:

9. Miscellaneous: •

If you are familiar with using Excel, you can enter a puzzle in SolvingSudoku.xls and then protect those cells. This will make it easier to avoid overwriting the puzzle you’re trying to solve. However, this is not necessary.

You can usually solve a puzzle quicker if you delete wrong digits from rows, columns, and sections as soon as you determine the correct digit for a given cell.

The spreadsheet is designed with protected cells so that you will not overwrite the program. However, the protection is not password protected, so you can make changes if you wish. If you do, it would be wise to save the original and use a copy with the filename changed so you can recover if you accidentally delete a feature or make an unwanted change.

View more...


Copyright ©2017 KUPDF Inc.