Solve a Rubik's Cube using Kociemba's algorithm
masterTo solve a cube, you must first run the computationally intensive precalculation step using Cube.initSolver(). This typically takes 4-5 seconds. Once initialized, you can call .solve() on a cube instance to get a string representing the moves required to solve it. The algorithm aims for a solution in 22 moves or less.
const Cube = require('cubejs');
// Perform precalculation (required once before solving)
Cube.initSolver();
const cube = new Cube();
cube.randomize();
// Returns an algorithm string, e.g., "D2 B' R' B L' B ..."
const solution = cube.solve();
console.log(solution);