The animation shows how a Sudoku is solved with this method. This is repeated until the allowed value in the last (81st) cell is discovered. The value in that cell is then incremented by one. If a cell is discovered where none of the 9 digits is allowed, then the algorithm leaves that cell blank and moves back to the previous cell. When checking for violations, if it is discovered that the "1" is not allowed, the value is advanced to "2". If there are no violations (checking row, column, and box constraints) then the algorithm advances to the next cell and places a "1" in that cell. Briefly, a program would solve a puzzle by placing the digit "1" in the first cell and checking if it is allowed to be there. Although it has been established that approximately 5.96 x 11 26 final grids exist, a brute force algorithm can be a practical method to solve Sudoku puzzles.Ī brute force algorithm visits the empty cells in some order, filling in digits sequentially, or backtracking when the number is found to be not valid. Backtracking is a depth-first search (in contrast to a breadth-first search), because it will completely explore one branch to a possible solution before moving to another branch. Some hobbyists have developed computer programs that will solve Sudoku puzzles using a backtracking algorithm, which is a type of brute force search.
0 Comments
Leave a Reply. |