Skip to content
coshzPublic

About

Rubik's cube solver

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Cube

GitHub License GitHub Release Hackage Crates.io PyPI npm

An ultra-fast, cross-platform Rubik's Cube solver engine built with modern C++17, implementing Kociemba's Two-Phase Algorithm.

✨ Features

  • ⚡ High Performance: Fast and resource-efficient core implementation.
  • 🌐 Multi-Language: Native bindings for Python, Rust, Haskell, and WebAssembly/TypeScript.
  • 📦 Cross-Platform SDK: Ships C dynamic/static libraries, Swift module (Cube.framework), and interactive CLI (icube).
  • 🛠️ Standalone: Zero external third-party dependencies.

📦 Language Bindings

Language Directory & Guide Package
Python bindings/python cube-python
Rust bindings/rust cube-rust
Haskell bindings/haskell cube-hs
TypeScript bindings/wasm @coshz/jscube

🚀 Quick Start

1. Interactive CLI (icube)

# Launch interactive solver
icube

# Or solve directly via state string
icube solve "UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB"
Click to view CLI screenshot shotsnap-1

2. C/C++ SDK Usage

A simple example

#include <cube/cube.hh>
#include <iostream>
#include <string_view>

int main()
{
  std::string_view cube = "FFLBURBURUUFRRRDDBUFBUFDFBRUDFBDFLLRDLLULLBRRULLFBBDDD";
  auto sol = cube::solve(cube);
  if(sol.is_success()) {
    std::cout << sol.maneuver << std::endl;
    if(cube::cubeId == cube::apply_maneuver(sol.maneuver, cube))
      std::cout << "solution verified\n"; 
    else 
      std::cout << "wrong solution\n";
  } else {
    std::cerr << "solve failed: " << cube::to_string(sol.status) << std::endl;
  }
}

Complete examples

  1. example/eg_c - C, built with make
  2. example/eg_cpp - C++, built with CMake

🛠️ Build & Install

Prerequisites

  • CMake 3.28+
  • C++17 compatible compiler (Clang, GCC, MSVC)
  • Ninja (Optional, recommended)

Instructions

# Configure & build core SDK
cmake -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

# Install C++ artifacts to system default path
cmake --build build --target install

📂 Repository Layout

.
├── amalg/            # Amalgamated C++ source (single-file distribution)
├── asset             # Project resources (snapshots, benchmark reports)
├── app/              # Source code for command-line tool `icube`
├── bindings/         # Language bindings
├── bench/            # Source code for benchmark 
├── cmake/            # CMake templates and modules
├── dev/              # Development scripts
├── include/          # Public headers
├── src/              # Core Two-Phase Algorithm implementation
└── test/             # Testing

📄 License

MIT © coshz

🔗 References

  1. http://kociemba.org/cube.htm

About

Rubik's cube solver

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages