This project contains an optimized Sudoku solver and puzzle generator for conventional 9x9 puzzles (as well as Sukaku "pencilmark" puzzles with clues given as negative instead of positive literals).
Note: Tdoku makes heavy use of SIMD instructions up to various flavors of AVX-512 when available. As a result it achieves its best performance on recent Intel hardware like the Ice Lake laptop. With older processors there are moderate declines in performance down to SSSE3, and precipitous declines with SSE2.
Build this project's libraries tools and tests as follows:
./BUILD.sh
./build/run_tests
You can build a simple test program that reads Sudoku (or 729-character pencilmark Sudoku) from stdin and displays the solution count and solution (if unique) like so:
# if you haven't done so, unzip the data
unzip data.zip
gcc example/solve.c build/libtdoku_static.a -O3 -o solve -lstdc++ -lm
# count solutions:
./solve < data/puzzles0_kaggle
# find single solution:
./solve 1 < data/puzzles0_kaggle
Or for an example of using the shared library via python bindings try:
# if you haven't done so, unzip the data
unzip data.zip
python3 example/solve.py data/puzzles0_kaggle
This Project is forked from tdoku. The purpose is adapt it to an library with an C interface. Easy for any language to call from. Difference from the original repo:
- TdokuSolve(): an utility function with simplified interface to solve an puzzle
- TdokuGenerate(): generate an puzzle
- TdokuRate(): rate an puzzle using solvers of tdoku library
- Benchmarks and other solvers and docs are removed so it only contains useful stuff for people who want to use the tdoku library.