Java Code that reads any NxN Sudoku-puzzle from a file and finds solution to it. Uses Recursive Backtracking algorithm and therefore a solution is always gauranteed, except in case of sudokus with no solution. Also displays how much time it takes to find solution to a particular puzzle.
- Download the Sudoku.jar along with the puzzle.txt file
- Make sure these files are in the same directory 3) Load your puzzle in the puzzle.txt file. Make sure you follow the format posted below. An example puzzle has been loaded. 0 stands for empty cells which the code tries to find solution to.
- From your terminal navigate to the directory where you saved the file
- Type in java -jar Sudoku.jar
- An alternative to Step 4 and 5 is typing java -jar space Drag and Drop the jar file. This only works for Linux and MacOS.
3 0 0 4 0 2 0 9 0
0 0 0 0 0 9 0 6 3
0 0 7 0 6 3 1 0 0
0 9 1 7 2 6 0 8 0
0 0 0 9 0 1 0 0 0
0 2 0 3 8 5 9 1 0
0 0 8 1 9 0 2 0 0
6 7 0 2 0 0 0 0 0
0 3 0 6 0 4 0 0 9