Yet another tool for automatic sudoku puzzle solving. Works with basic puzzle rules.
See Sudoku Solver Fronted project for user web interface module.
- Docker 20.10+ (for amd64 linux platform only)
or
Pull the latest build available:
docker pull kalinbob/sudoku-solver:latest
Or use one of stable release versions (see release notes for details).
Run pulled <VERSION>
on <PORT>
of your choice:
docker run --name=sudoku-solver -d -p <PORT>:5000 kalinbob/sudoku-solver:<VERSION>
Add this option for writing logs to<DIRECTORY>
on the host:
-v <DIRECTORY>:/app/logs
pip install -r requirements.txt
python -m pytest -v
On Windows (e.g. on port 5000):
cd src/
set FLASK_APP=app.main
python -m flask run -h 0.0.0.0 -p 5000
Using curl
(on Windows 10 works with v.1803 +):
curl -X GET http://<host>:<port>/v1/health
Example:
curl -X GET http://localhost:5000/v1/health
curl -X POST http://<host>:<port>/v1/solve -H "Content-type:application/json" -d "{\"grid\": <grid>}"
Here <grid>
is a 9x9 nested array.
Example:
curl -X POST http://localhost:5000/v1/solve -H "Content-type:application/json" -d "{\"grid\": [[2, 4, 7, null, 9, 1, null, 6, 8],[1, null, 5, 7, 6, null, 3, null, null],[8, 6, null, 4, null, null, null, null, 7],[9, null, null, 2, null, 6, null, null, null],[null, null, null, 9, 4, 7, 6, 8, null],[6, null, 4, null, 5, null, null, 1, 9],[7, null, null, null, 3, null, 9, 2, null],[4, null, 9, 6, null, null, null, null, null],[null, null, null, null, null, null, 4, null, 3]]}"
Normal response data is JSON:
{"status": "ok", "grid": <UPDATED_GRID>}
curl -X GET http://<host>:<port>/v1/get_task -H "Accept:application/json"
Example:
curl -X GET http://localhost:5000/v1/get_task -H "Accept:application/json"
Normal response data is JSON:
{"status": "ok", "grid": <PUZZLE_GRID>}
Encode sudoku puzzle to text file (see format requirements) and pass it to the script:
python src/solver.py path/to/sudoku-file
The script attempts to solve it and (if task seems valid) writes the solution to path/to/sudoku-file-solution
.
Sudoku file is a text file designed to save Sudoku tasks and solutions.
- File encoding: UTF-8.
- The file must contain 9 lines.
- Each string must include 9 digits or spaces. Other characters are allowed and ignored. Lines of other characters are allowed and ignored.
Example of a valid Sudoku file:
*************
*123*456*789*
* *456*789*
*123*456* *
*************
*123* *789*
* * * *
*1 4*56 * 9 *
*************
22*456*78
*1 * * 9*
*123*456*789*
*************
Development is in progress.
Lead maintainer: @balex89
Feel free to contact us: [email protected]