rubik()

Solves a given Rubik's Cube state by providing the sequence of moves required to solve it.

Optimal solutions for the Rubik's Cube

Syntax

rubik(state)
rubik(state, target)

Parameters

Parameter Type Description Comment
state String Cube state in color notation Must follow the color encoding
target String Target configuration (optional) Defaults to a standard solved cube

Return Value

Examples

Solve a scrambled cube using its color state

rubik("ROBRWYWOY BYGBGBOBG OGOWRGRRR WWWOBYBRB GYRBOROGG WOYWYGYWY");

Result:
R' U B' R' L' B' L' F' L B2 L D B2 D R2 U2 D' F2 U' B2 R2

Explanation:
This sequence of moves will transform the given cube state into the solved configuration. The notation follows standard Rubik’s Cube move notation:

  1. R (Right face clockwise), R' (Right face counterclockwise)
  2. U (Upper face clockwise), U' (Upper face counterclockwise)
  3. B2 (Back face rotated twice), etc.