Rubik's cube

Turn it, scramble it, solve it. The same state drawn three ways: in three dimensions, unfolded as a net, and written as a permutation of the cube group.

Enter a sequence of moves, or start from a scrambled cube.

Enter a maneuver, then step or play it.

    notation
    U D L R F Bquarter turn of that face, clockwise
    u d l r f bthe same turn counter-clockwise, so rfu is R' F' U'
    ' 2 ^2 ^-1inverse, half turn, Sage style exponents
    M E Smiddle slice, following L, D and F
    *F   >Fslice and whole-cube turn, as in geometer.org's Rubik
    x y zwhole-cube turns
    Rw   2R   2-3Rwide and deep layers, for bigger cubes
    (R U)3   (R U)'repeat a group, or invert it
    drag to rotate
    click a facelet
    as a permutation each cycle says where facelets go, numbered as in the unfolded cube.

    What this is

    A Rubik's cube that lives entirely in the browser: no server, and nothing to install. The geometry, the solver and every drawing are written in Rust and compiled to WebAssembly using [trunk](https://trunk-rs.github.io/trunk/).

    Three views of one state

    The 3D view is a perspective projection you can drag to rotate and zoom, with named camera presets for reproducible figures. The net is the cube unfolded flat, optionally with facelet numbers, and you can ring any set of facelets by clicking them or by typing a list such as 1,3,8-11. The permutation panel writes the state in disjoint cycle notation, each cycle saying where a facelet travels. The numbering, the net layout and the colors follow SageMath's sage.groups.perm_gps.cubegroup.

    Solving

    The solve button runs Kociemba's two-phase algorithm, which reaches the solved state in about twenty moves. Phase one takes the cube into the subgroup H = <U, D, R2, L2, F2, B2> and phase two finishes inside it. There is more on how and why it works in Magic Squares and Cubes.

    Notation

    The parser reads WCA notation (R2 U F'), the SageMath product (R^2*U*F^-1), and the crammed macro language of Tom Davis's Rubik, where rfu means R' F' U'. Slices, wide turns, whole-cube rotations and repeated groups such as (R U)3 all parse, and the notations can be mixed in one line. Cubes from 2x2 to 7x7 can be drawn and turned; the solver is for the 3x3.

    Exporting the drawings and animations

    Every view exports as SVG: a still, the flat net, a whole maneuver as a grid of labeled steps, an animated SVG that plays inside an <img> tag, or a self-contained HTML player. The embed snippet gives you an <iframe> of this page, state and all, still interactive. The same renderer is a command line tool and a Python module, which is how the figures in the marimo notebook are drawn.

    Free and open source. Source on GitHub · My personal blog