Sudoku solver
- JDK 12 (lower versions might work)
- IntelliJ IDEA (to build and run tests, as there is no build script provided)
Plain text file containing 9 rows of 9 numbers (0-9). Each number represents a cell. 0 indicates an empty cell. The file can contain tabs or spaces or line breaks for readability. All those separators will be ignored.
The only required and allowed argument is absolute or relative path to an input file. See SudokuSolverArgs.java.
- SudokuSolverApp – contains main method of the application
- SudokuSolverArgs – command line arguments parser (check for input format)
- SudokuBoard – represents a Sudoku puzzle, allows getting a cell value, or setting a cell value, also provides mechanics to validate cell input values according to Sudoku rules.
- SudokuBacktrackingSolver – implements decision making conditions for backtracking search of the puzzle solution.
Unit tests for SudokuBacktrackingSolver are located in SudokuSolverTests class.
Test cases can be found in sudoku-solver/test/resources folder.
Required examples are marked as sample2 and sample3.
Sample4 contains a Sudoku designed against brute force algorithms, such as backtracking. It takes approximately 1 minute to complete on AMD-FX-8320.
Sample files with “-bad” suffix contain unsolvable Sudoku examples.