Simple greedy algorithm to solve Sudoku puzzles.
Boredom at it's finest.On the folder src/data you can find a file with the Sudoku to solve.
The format on it will be:
2 X 9 X X X 6 X X
X 4 X 8 7 X X 1 2
8 X X X 1 9 X 4 X
X 3 X 7 X X 8 X 1
X 6 5 X X 8 X 3 X
1 X X X 3 X X X 7
X X X 6 5 X 7 X 9
6 X 4 X X X X 2 X
X 8 X 3 X 1 4 5 X
Where 'X' is an empty cell.
To start the solver, just click on the board. Tha algorithm is animated, so you can see the steps.
A simple view on the algorithm used would be:
- Find the first empty cell
- Find all possible values for the cell
- For each possible value
- Set the value
- Solve the grid
- If the grid is solved, return
- If the grid is not solved, reset the value and go to step 1
- If no value can be set, return false
This uses recursion and backtracking to achieve the solution.
Made with:
- Memoization technique
- Animation
- Solving Sudoku
- Metrics (See the console for details)
- Light and dark themes (default: light)