cube-python
High-performance Rubik's Cube solver Python bindings powered by C/C++ FFI.
Installation
pip install cube-python
Quickstart
import pycube
from pycube import SolveError
# Default solved cube string representation
print(f"Target State: {pycube.CUBE_ID}")
# Validate state solvability
scrambled = pycube.facecube("U F U' L2 R L' D2 B")
if pycube.solvable(scrambled):
try:
# Find solution sequence
solution = pycube.solve(scrambled,good=22)
print(f"Solution: {solution}")
# Apply solution to verify end state
end_state = pycube.facecube(solution, scrambled)
assert end_state == pycube.CUBE_ID
except SolveError as e:
print(f"Failed to solve cube: {e}")
📖 API Reference
import pycube
from pycube import SolveError, CUBE_ID, PermFormat
Functions
| Function | Description |
|---|---|
cube_init(use_symmetry=True,table_dir="") |
use symmetric pruning tables and customized table directory. |
solve(src,tgt=CUBE_ID,good=22) |
Solve cube state src; stops as soon as a solution <= good moves is found. Returns solution string or raises SolveError. |
facecube(maneuver,cube=CUBE_ID) |
Applies move sequence (e.g., "U F U' L2") to a cube state and returns the new state. |
solvable(cube) |
Returns True if the 54-character state string is physically solvable. |
permutation(ms_or_cube,fmt=PermFormat.Cycle) |
Returns a permutation representation for a move sequence or state. |
Constants & Exceptions
| Name | Type | Description |
|---|---|---|
CUBE_ID |
str |
Constant representing the standard solved state UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB. |
PermFormat |
IntEnum |
Permutation output format. Members: Face,Cubie,Cycle. Defaults to Cycle. |
SolveError |
Exception |
Raised when the state is invalid or unsolvable. |
📄 License
MIT © coshz
Metadata
Release files for cube-python 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cube_python-0.5.1.tar.gz | 27.5 kB | Without provenance | Details for cube_python-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cube_python-0.5.1-cp312-cp312-macosx_10_15_x86_64.whl | CPython 3.12 | CPython 3.12 | macOS 10.15+ x86-64 | Details for cube_python-0.5.1-cp312-cp312-macosx_10_15_x86_64.whl |
Total release size: 146.3 kB
Release files / cube_python-0.5.1.tar.gz
| Download URL | cube_python-0.5.1.tar.gz |
|---|---|
| Size | 27.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4663d29705f281d0aeddc2a7fd51188e734725cf9c1fe3a707befc2f3836f954
|
|
BLAKE2b-256 checksum How to use checksums |
094a4c2f17a4ce527f3c5d513dc7dfc2f754f1005df860693edcdd143b420f62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / cube_python-0.5.1-cp312-cp312-macosx_10_15_x86_64.whl
| Download URL | cube_python-0.5.1-cp312-cp312-macosx_10_15_x86_64.whl |
|---|---|
| Size | 118.8 kB |
| Tags | CPython 3.12 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
63c46d4bb7bde5ced22c77ac2f9b7d1fad08d24ac962087a0d38c9e942cf1bad
|
|
BLAKE2b-256 checksum How to use checksums |
622b08685a50b36f6f92074cc59b295f2b7e771c4386b62d02c623f978d10fcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Security for cube-python 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.