Excel Sudoku Solver Code

• • • Introduction I started trying to develop a Sudoku solver in Excel using VBA. After a few interactions with Excel, I moved to Visual Basic using VS2005. After doing a version of the program to deal with 9x9 (classic) Sudokus, I also adapted the code to solve Samurai Sudoku (5 overlapping 9x9 grids). I wanted to provide both a source and demo - as there aren't too many fully featured solvers I could find in Visual Basic to learn from. The logic based solvers and the UI probably took the most work - the actual brute force solver was actually pretty quick to code.

Sudoku Solver – Excel Games Puzzle. Sudoku is one of the famous Math games that will test your memory capability. Here is the list of instructions about how to play this game.

Terminology This article doesn't go in depth into the rules of Sudoku or the detail of how to solve Sudoku puzzles. Just use a search engine if you want background on this. However, the basic principle is that the numbers 1-9 are placed into the rows, columns, and subgrids so that every row, column, and subgrid only contain each digit once. Some terms however are used below to explain the code.

• Cell - individual cell where digits 1-9 can be placed. Shablon awp ksgo. • Clues/givens - in the first image above, the second and third cells hold clues of 7 and 6, respectively.

Codeware compress software price. • Candidates/pencilmarks - in the image above, the first cell contains three candidates (2, 3, and 9). It is important when trying to solve a puzzle to keep track of the various candidates. • Row - a group of 9 cells going horizontally down the screen. • Column - a group of 9 cells going vertically down the screen. • Subgrid - a group of 9 cells arranged in a 3x3 grouping. • Peers - in a 9x9 classic grid, each cell can 'see' up to 20 other cells (the other cells in the row, column, and subgrid). Due to the rule that no digit can be repeated in a row, cell, or subgrid, if you place a digit as the solution to a cell, that digit can be removed as a candidate from each of its peers.

Peers for a Samurai Sudoku are a bit different, as some cells will have a greater number of peers due to the five overlapping grids. Points of Interest The solver will try to solve puzzles using logical steps, but will also resort to a brute force algorithm for tougher puzzles. Consequently, it can solve most classic 9x9 Sudoku puzzles pretty much instantly, or most Samurai puzzles within a couple of seconds (depending on the computer).

Excel Sudoku Solver Code

Admittedly, there are C++ solvers that can solve hundreds or thousands of puzzles per second. However, I wanted something that would solve puzzles reasonably quickly, but also be able to step through puzzles and show why particular solving steps were taken. There is a custom control which uses GDI+ to paint clues and candidates (pencilmarks).