Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cau777/sudoku_solver
An algorithm to solve sudoku puzzles and a web interface to visualize the solution's steps.
https://github.com/cau777/sudoku_solver
react rust rust-wasm sudoku sudoku-generator sudoku-solver typescript wasm
Last synced: about 1 month ago
JSON representation
An algorithm to solve sudoku puzzles and a web interface to visualize the solution's steps.
- Host: GitHub
- URL: https://github.com/cau777/sudoku_solver
- Owner: cau777
- License: mit
- Created: 2022-07-20T00:30:18.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-31T23:09:46.000Z (almost 2 years ago)
- Last Synced: 2024-04-23T23:43:30.961Z (8 months ago)
- Topics: react, rust, rust-wasm, sudoku, sudoku-generator, sudoku-solver, typescript, wasm
- Language: Rust
- Homepage: https://caua-rinaldi.dev/projects/sudoku-solver
- Size: 3.44 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sudoku Solver
An algorithm made in rust to solve sudoku puzzles of various sizes efficiently. It's implemented in Rust and runs in the
browser using Web Assembly. The project includes a modern interface made in React to visualise the algorithm
step-by-step.## Features
* 3 board options: 4x4 9x9 16x16
* Generation of random Sudoku puzzles
* Algorithm made in Rust to solve puzzles in milliseconds
* Step-by-step visualization of the solution with explanations## How the [algorithm](https://github.com/cau777/sudoku_solver/blob/master/wasm/src/sudoku_solver.rs) works
It was inspired by some real-world Sudoku solving techniques, and aims to minimize guesses. The algorithm has a recursive
idea, but is actually implemented iteratively using a Stack, It also uses bitwise operations
whenever possible to improve performance massively.
1) Load the board from a string representation
2) Search for cell whose value can be inferred. This is done in 2 ways:
* Sole candidate: when a cell can only contain one number, because all the other ones are already taken in the row/column/block.
* Unique candidate: when, in a row/column/block, a number can only be put in one cell. Because every number must appear
once in every row/column/block, if only one cell can fit a determined number, it's definitely there.
3) If the step 2 had success, complete that cell and do it again.
4) Check if the board is complete, if so, return.
5) Now, only guesses remain, so we have to find the cell with the least number of candidates.
6) Guess a number on that cell and execute step 2 in the modified board.This [website](https://www.conceptispuzzles.com/index.aspx?uri=puzzle/sudoku/techniques) explains some of the logic.
## Screenshots
* ![Empty board](https://github.com/cau777/sudoku_solver/blob/master/screenshots/empty_board.png)
* ![Solution step](https://github.com/cau777/sudoku_solver/blob/master/screenshots/solution_step.png)