Sudoku puzzles are created with the intent to be solved by human players with pencil, however, as with many things, they can be solved much faster with computers. The layout of a Sudoku puzzle is made up of nine rows and nine columns that make up eighty-one total squares. Sudoku puzzles have nine nonoverlapping zones, each composed of three grid rows and three grid columns, or nine grids total. In each of these zones all numbers must be unique (numbered one to nine). Likewise, each number in a row or column must be unique (one-nine). Players must use deduction and reasoning to solve these puzzles without making mistakes and arrive at the solution. The AlgorithmSolver is an algorithm that does exactly what the name suggests, it solves Sudoku puzzles. The goal is to provide the solution to the puzzle with the inputs provided. Since each Sudoku puzzle has only one solution, the solver does not need to try to find multiple solutions. Input and OutputSolver takes the Sudoku puzzle as input, which is provided as a two-dimensional nine-by-nine array. Before any solution, the algorithm first checks whether the input is valid. To do this, you first make sure you get a two-dimensional nine-by-nine array by running it through a nested for loop making sure there are the right number of cells. Then check to make sure there are no row, column or block violations (such as there being more than 2 of the same number in a row, column or block). On top of that it doesn't allow you to enter numbers greater than nine. The way it does this is to only allow input from zero to nine, if the input does not meet this condition, the input is replaced with white space. After the solution is finished... halfway through the paper... be aware of this and you may not notice the change in the white spaces. This could be a potential problem if the user doesn't notice before pressing solve, which would cause the solver algorithm to not provide the solution the user wants. Summary The Sudoku solver is an algorithm that takes the input of a Sudoku and attempts to solve it, returning a completely complete Sudoku as a two-dimensional array. Based on a brute force algorithm, it's not the most efficient algorithm, however it gets the job done. The addition of the option vector is an attempt to optimize the standard brute force method and significantly simplifies the algorithm. Although the algorithm is not the most efficient, the fact that the input size is always the same (a nine by nine matrix) and is not particularly large, the inefficiency of the algorithm is not too burdensome.
tags