lib_sudoku
A python library built in rust to read, solve, and generate sudoku puzzles.
It can read and solve 9 million puzzles in under 10 seconds.
Installation
For easy installation, run:
pip install lib_sudoku
If you prefer, you can build the code yourself from source. To do this, run
git clone https://github.com/shaggysa/lib_sudoku.git
cd lib_sudoku
maturin build --release
pip install target/wheels/lib_sudoku*.whl
Basic Usage
A solver function, generator function, and reader class are currently available. A sample of python code to test each of these functions is available below:
First, import the sudoku library and the time library:
import lib_sudoku as sudoku
import time
Then, create a puzzle reader class with the puzzles you want to solve:
reader = sudoku.PuzzleReader("https://raw.githubusercontent.com/shaggysa/lib_sudoku/master/puzzles.csv", True)
To test the solver, run a speedtest function and pass in the reader:
sudoku.async_speedtest(reader)
sudoku.synchronous_speedtest(reader)
To test the generator, simply call the gen_unsolved function and pass in the number of hints you want the final puzzle to have
you can also time it if you would like:
num_hints = 24
start_gen = time.time()
sudoku.gen_unsolved(num_hints)
print(f"Generated a puzzle with {num_hints} hints in {(time.time() - start_gen)*1000} milliseconds.")
Note that the less hints you want in your unsolved puzzle, the longer it will take for the generator to make it.
In my testing, it usually takes under a millisecond to generate a puzzle with 30 hints, but it can take up to 50ms for a puzzle with 24 hints.
Generating puzzles with under 23 hints does not work because it will get stuck.
Note: If you want to try out the speedtest function on the large (9 million puzzle dataset), you can download it at https://www.kaggle.com/datasets/rohanrao/sudoku.
Just make sure to move the extracted file into your working directory and to adjust the PuzzleReader class parameters to be ("sudoku.csv", False)
Metadata
Release files for lib-sudoku 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lib_sudoku-2.2.0.tar.gz | 100.8 kB | Details |
Built distributions (wheels)
Total release size: 22.3 MB
Release files / lib_sudoku-2.2.0.tar.gz
| Download URL | lib_sudoku-2.2.0.tar.gz |
|---|---|
| Size | 100.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92151c7480c57e027730782c7c65cc6d4daa7ad8011105f476cd428e73e82d64
|
|
BLAKE2b-256 checksum How to use checksums |
331dbd23e43acc6fa6cd0f994dff656b8b3ce3e1c8aad8598d43c95d757f625f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / lib_sudoku-2.2.0-cp313-cp313-win_amd64.whl
| Download URL | lib_sudoku-2.2.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ffa8fbdfcf4828bf3ee859d06e579e4bfbafb3c154cf04dfd28223433da63362
|
|
BLAKE2b-256 checksum How to use checksums |
06f4aab27101a59b88fa3a7157ca05b9627ac49c3189ae062a86a4b698a059de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | lib_sudoku-2.2.0-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
01197d34c8f2b33a73c3da44a5a35a12c731885988822a8c8b3cbf1fa5a1b1e9
|
|
BLAKE2b-256 checksum How to use checksums |
f31409a34fa8677eeaea308be18645ba99e6422e8bb4e16e08da03cd671c559f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | lib_sudoku-2.2.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
075275a282072681c7112d72546e069896e326c1ea5ebb854a5c311ad4763134
|
|
BLAKE2b-256 checksum How to use checksums |
44b29a4750f5ab438c03965d64c84942c27ddd327cf5a7e9f9e31c7f17440ce0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp312-cp312-win_amd64.whl
| Download URL | lib_sudoku-2.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7057d2c59e6af65401008cf85be395bed79552a45b276124678cedd8026e60ab
|
|
BLAKE2b-256 checksum How to use checksums |
c1b4cc0aa8eb5a1367617b417e0f9bcb56b0d66375e447e55b6899724561cc40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | lib_sudoku-2.2.0-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
a76db5fd763db88e6596556b39da22efdf44bc8ba6a30c68df2fe8594acfb617
|
|
BLAKE2b-256 checksum How to use checksums |
6ef42a214657c3825e8eea38feee0424e99cf929357ea43e94a75dce872a8aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | lib_sudoku-2.2.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
73e905b01a3259f5464683c23e114bda6fa37b455509a48f335420f2487d0c14
|
|
BLAKE2b-256 checksum How to use checksums |
3ac7e3953188447944d988672dc7cb9244329dfe31ab68ef8242c15c4a6c4522
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp311-cp311-win_amd64.whl
| Download URL | lib_sudoku-2.2.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e6f06796c51f097a9e15be6154c1c2e0d89ad2335d32832f49d839a72170b64d
|
|
BLAKE2b-256 checksum How to use checksums |
6e0d88a79fdbcb75eae4674fd93440e9760cb73212a1af59d52759b8ff899393
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp311-cp311-manylinux_2_34_x86_64.whl
| Download URL | lib_sudoku-2.2.0-cp311-cp311-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.11 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
8903f8aeb963c6e2b4d6ca29e90ba2d51ea458ac58afb03802c74aa046cbac6a
|
|
BLAKE2b-256 checksum How to use checksums |
a3506455dabcafbaa12a88fb4f8f67158888a500ec1b93a89491d7bdf414d38b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | lib_sudoku-2.2.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f9b6469984abd9ff20b3a18b828fc51868b08e9be45a1d9f2d2b7b15f05425dd
|
|
BLAKE2b-256 checksum How to use checksums |
a7b3a769217d45b7b4cebee1d825d778e8e6dcb40bfa09e28dc7f79955f63496
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp310-cp310-win_amd64.whl
| Download URL | lib_sudoku-2.2.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
db5f46a6216b2ab491ff8f553f170f6d88006b00eb17ae50979492df9235db9c
|
|
BLAKE2b-256 checksum How to use checksums |
1cb240914d0ae469adbad83dab3fcc88f162a05946f7e48f678b6f56fab1bfa8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp310-cp310-manylinux_2_34_x86_64.whl
| Download URL | lib_sudoku-2.2.0-cp310-cp310-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
493470752ee12aa6493b9852442b7d16e042534e28f1e0b78a9d01c8d5780d4f
|
|
BLAKE2b-256 checksum How to use checksums |
2c723618793b3617e3634271b9da73e0735b709cd0e232f9ad3116f1b5e83ed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | lib_sudoku-2.2.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f6769e1aa4a0e97d108a47be2cac5a5983ce18943d83ab0611fa6784df1c66f7
|
|
BLAKE2b-256 checksum How to use checksums |
6f1dfbaa8f4fa1d2c00bcbed56fc26ee2259c40267b03df84ecbac6264f701a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp39-cp39-win_amd64.whl
| Download URL | lib_sudoku-2.2.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
501a48023eea0bfad2752b83576b66bf9f29d31109248b8797e91f59d0716479
|
|
BLAKE2b-256 checksum How to use checksums |
7eced6944e5a8d8fc3f57fbd3f9b3bb04bfc0037f142ac7d70051360f748af34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp39-cp39-manylinux_2_34_x86_64.whl
| Download URL | lib_sudoku-2.2.0-cp39-cp39-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
dddf42f5b407adc467ab3ffbdada9e9381635f8de5d7c7fbb1c27c712c9d8c1c
|
|
BLAKE2b-256 checksum How to use checksums |
a4be27accaa20ca0323ef014396f25247138cf112029c37d572696ab7e7020cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | lib_sudoku-2.2.0-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
366ce6b9e6224e9b3613a5fecf29ccbc8c8e0dcb16568b078030e04a3ee9be66
|
|
BLAKE2b-256 checksum How to use checksums |
f9f8abc4ed175b95aa41eacde2e0ddc6f15b7848c50b55181e90e1b50c838023
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp38-cp38-win_amd64.whl
| Download URL | lib_sudoku-2.2.0-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
26d48462d00a47481b5978ea8458bb0c1bec8634783f9ecb8aec2b40036db807
|
|
BLAKE2b-256 checksum How to use checksums |
5106ce367a1f3fa89d54b163cdcf645889df09690dd9c96b3ed5de2ff61242e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp38-cp38-manylinux_2_34_x86_64.whl
| Download URL | lib_sudoku-2.2.0-cp38-cp38-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.8 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
d3032169be452459b22445d46a25a93ee75f761aacf1ec17354d68c4b107fa53
|
|
BLAKE2b-256 checksum How to use checksums |
21e5267813795dfcec9b8f64062176fdd5512145dbe85433106ee3c77aa02ef6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / lib_sudoku-2.2.0-cp38-cp38-macosx_11_0_arm64.whl
| Download URL | lib_sudoku-2.2.0-cp38-cp38-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.8 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
12e4a28dc4768cb4530b44c98841cabf2e2b14a767e3b117ceb5bbcc4ca5ac25
|
|
BLAKE2b-256 checksum How to use checksums |
feb8457e85270078fc08f058eb832b681cb9e184d07e041c9c9756449df068a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|