Skip to content
Rubik's cube simulator and solver, IPython/Jupyter
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Rubik's cube simulator and solver in Jupyter notebook

  1. View the interactive Binder notebook.
  2. The notebook should render on Github: cube.ipynb.
  3. Use nbviewer.

Of course, forks and comments are welcome!

Setting up


position = reset_cube() will reset the cube to a completed position


view_cube() will visualize the six sides of the cube


RotateDown(n) will rotate the cube down, n times. The full list of rotations is below.

RotateDown(n) #rotates cube down
RotateRight(n) #rotates cube right
RotateCC(n) #rotates cube counter-clockwise

Playing with the cube

Moves will execute the "Left-Up" move, n times. The list of moves is below. #Left-Up #Middle-Up #Right-Up #Top-Left #Middle-Left #Bottom-Left #Right Face, Left-Up (sometimes called Front-Left) #Right Face, Middle-Up #Right Face, Right-Up (sometimes called Back-Left)


mixup(n) will make n random moves on the cube, "mixing it up"


solve() will (should!) solve the cube, and print the raw number of moves. This is effectively the algorithm I use when I solve Rubik's cubes.

Have fun!

I sure enjoyed this project. Let me know if there are bugs or comments :-)

You can’t perform that action at this time.