A blazing fast sudoku library buit in rust
Project description
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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lib_sudoku-2.2.0.tar.gz.
File metadata
- Download URL: lib_sudoku-2.2.0.tar.gz
- Upload date:
- Size: 100.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92151c7480c57e027730782c7c65cc6d4daa7ad8011105f476cd428e73e82d64
|
|
| MD5 |
f4f52994144f94cdd556e210326f6123
|
|
| BLAKE2b-256 |
331dbd23e43acc6fa6cd0f994dff656b8b3ce3e1c8aad8598d43c95d757f625f
|
File details
Details for the file lib_sudoku-2.2.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffa8fbdfcf4828bf3ee859d06e579e4bfbafb3c154cf04dfd28223433da63362
|
|
| MD5 |
0ff62854a45df21b89b71d2366c9ce65
|
|
| BLAKE2b-256 |
06f4aab27101a59b88fa3a7157ca05b9627ac49c3189ae062a86a4b698a059de
|
File details
Details for the file lib_sudoku-2.2.0-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01197d34c8f2b33a73c3da44a5a35a12c731885988822a8c8b3cbf1fa5a1b1e9
|
|
| MD5 |
c28e1d10f296d4bc83bda58f7aa7bafb
|
|
| BLAKE2b-256 |
f31409a34fa8677eeaea308be18645ba99e6422e8bb4e16e08da03cd671c559f
|
File details
Details for the file lib_sudoku-2.2.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
075275a282072681c7112d72546e069896e326c1ea5ebb854a5c311ad4763134
|
|
| MD5 |
73ab97b6923597aa3c51892f2751a572
|
|
| BLAKE2b-256 |
44b29a4750f5ab438c03965d64c84942c27ddd327cf5a7e9f9e31c7f17440ce0
|
File details
Details for the file lib_sudoku-2.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7057d2c59e6af65401008cf85be395bed79552a45b276124678cedd8026e60ab
|
|
| MD5 |
96a068b5b2a4327518ba520af6ca9886
|
|
| BLAKE2b-256 |
c1b4cc0aa8eb5a1367617b417e0f9bcb56b0d66375e447e55b6899724561cc40
|
File details
Details for the file lib_sudoku-2.2.0-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a76db5fd763db88e6596556b39da22efdf44bc8ba6a30c68df2fe8594acfb617
|
|
| MD5 |
66daa42d301e12c8415eb206c5939207
|
|
| BLAKE2b-256 |
6ef42a214657c3825e8eea38feee0424e99cf929357ea43e94a75dce872a8aa7
|
File details
Details for the file lib_sudoku-2.2.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73e905b01a3259f5464683c23e114bda6fa37b455509a48f335420f2487d0c14
|
|
| MD5 |
1301040787671fe20a4770c46ee3d702
|
|
| BLAKE2b-256 |
3ac7e3953188447944d988672dc7cb9244329dfe31ab68ef8242c15c4a6c4522
|
File details
Details for the file lib_sudoku-2.2.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6f06796c51f097a9e15be6154c1c2e0d89ad2335d32832f49d839a72170b64d
|
|
| MD5 |
e221d27487e352791afd84e5835aeb4f
|
|
| BLAKE2b-256 |
6e0d88a79fdbcb75eae4674fd93440e9760cb73212a1af59d52759b8ff899393
|
File details
Details for the file lib_sudoku-2.2.0-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8903f8aeb963c6e2b4d6ca29e90ba2d51ea458ac58afb03802c74aa046cbac6a
|
|
| MD5 |
e440d5e5a20c2afa2b0fa88ed4aa1ccf
|
|
| BLAKE2b-256 |
a3506455dabcafbaa12a88fb4f8f67158888a500ec1b93a89491d7bdf414d38b
|
File details
Details for the file lib_sudoku-2.2.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9b6469984abd9ff20b3a18b828fc51868b08e9be45a1d9f2d2b7b15f05425dd
|
|
| MD5 |
44fb829043e7435460ad72a0853079a0
|
|
| BLAKE2b-256 |
a7b3a769217d45b7b4cebee1d825d778e8e6dcb40bfa09e28dc7f79955f63496
|
File details
Details for the file lib_sudoku-2.2.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db5f46a6216b2ab491ff8f553f170f6d88006b00eb17ae50979492df9235db9c
|
|
| MD5 |
6a2ff16074e13ddc29d0632a77e962b6
|
|
| BLAKE2b-256 |
1cb240914d0ae469adbad83dab3fcc88f162a05946f7e48f678b6f56fab1bfa8
|
File details
Details for the file lib_sudoku-2.2.0-cp310-cp310-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
493470752ee12aa6493b9852442b7d16e042534e28f1e0b78a9d01c8d5780d4f
|
|
| MD5 |
ccca25a57e097e472d92cae64339af57
|
|
| BLAKE2b-256 |
2c723618793b3617e3634271b9da73e0735b709cd0e232f9ad3116f1b5e83ed6
|
File details
Details for the file lib_sudoku-2.2.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6769e1aa4a0e97d108a47be2cac5a5983ce18943d83ab0611fa6784df1c66f7
|
|
| MD5 |
94d91810495c1131223bf798a8f1accc
|
|
| BLAKE2b-256 |
6f1dfbaa8f4fa1d2c00bcbed56fc26ee2259c40267b03df84ecbac6264f701a1
|
File details
Details for the file lib_sudoku-2.2.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
501a48023eea0bfad2752b83576b66bf9f29d31109248b8797e91f59d0716479
|
|
| MD5 |
3026abdb5cbcab0bd18cd620db307f0e
|
|
| BLAKE2b-256 |
7eced6944e5a8d8fc3f57fbd3f9b3bb04bfc0037f142ac7d70051360f748af34
|
File details
Details for the file lib_sudoku-2.2.0-cp39-cp39-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp39-cp39-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dddf42f5b407adc467ab3ffbdada9e9381635f8de5d7c7fbb1c27c712c9d8c1c
|
|
| MD5 |
707ecbff2b868a2a279147f2d54c71ac
|
|
| BLAKE2b-256 |
a4be27accaa20ca0323ef014396f25247138cf112029c37d572696ab7e7020cc
|
File details
Details for the file lib_sudoku-2.2.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
366ce6b9e6224e9b3613a5fecf29ccbc8c8e0dcb16568b078030e04a3ee9be66
|
|
| MD5 |
91b7b1128f1ad428703f50a5512d44b1
|
|
| BLAKE2b-256 |
f9f8abc4ed175b95aa41eacde2e0ddc6f15b7848c50b55181e90e1b50c838023
|
File details
Details for the file lib_sudoku-2.2.0-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26d48462d00a47481b5978ea8458bb0c1bec8634783f9ecb8aec2b40036db807
|
|
| MD5 |
96a27d6ca060e37c23eaa340ee0fc2fa
|
|
| BLAKE2b-256 |
5106ce367a1f3fa89d54b163cdcf645889df09690dd9c96b3ed5de2ff61242e2
|
File details
Details for the file lib_sudoku-2.2.0-cp38-cp38-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp38-cp38-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.8, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3032169be452459b22445d46a25a93ee75f761aacf1ec17354d68c4b107fa53
|
|
| MD5 |
619eaad17581109c3c595c7ebcf13faa
|
|
| BLAKE2b-256 |
21e5267813795dfcec9b8f64062176fdd5512145dbe85433106ee3c77aa02ef6
|
File details
Details for the file lib_sudoku-2.2.0-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: lib_sudoku-2.2.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12e4a28dc4768cb4530b44c98841cabf2e2b14a767e3b117ceb5bbcc4ca5ac25
|
|
| MD5 |
c58b1d524f7bb12dd53005c7cb4a42be
|
|
| BLAKE2b-256 |
feb8457e85270078fc08f058eb832b681cb9e184d07e041c9c9756449df068a9
|