We will be using a 3x3 cube for this challenge.
Rubik's cubers have their own notation for movements on the cube:
- Each of the 6 faces has a clockwise turn notated with a single capital letter:
UDLRFB. There are three additional letters
MESdenoting the three center slices.
- Counterclockwise rotations have a prime symbol appended:
U => U'. The prime symbol for this challenge will be an ASCII apostrophe.
- A move rotated twice (either CW or CCW) has a
U => U2.
- A move cannot be rotated twice and prime at the same time.
- Individual moves are separated by spaces:
U F D' B2 E M' S2
- This challenge will not be using lowercase letters, which signify moving two layers at the same time.
Commutators, coming from group theory, is an operation of two elements \$g,h\$ such that \$\left[g,h\right]=ghg^\prime h^\prime\$, where \$g^\prime\$ is the inverse of \$g\$, e.g.
R U F' => F U' R'
Rubik's cubers use a similar notation to describe commutators, used for swapping two or three pieces without disturbing any others.
Some examples of commutators:
[F U R, D B] = (F U R) (D B) | (R' U' F') (B' D') [F' U2 R, D B2] = (F' U2 R) (D B2) | (R' U2 F) (B2 D') // note how B2 and U2 aren't primed
Given a Rubik's cube commutator, expand the commutator to list out all the moves performed in it.
Input is a Rubik's cube commutator.
Each side of the commutator are guaranteed to be at least 1 move long.
Each part of the commutator can be a separate value.
Each move in each commutator part can be separate values, as long as a CCW/prime or double move is within the value of the move (e.g.
[[R2], ...] is valid, but
[[R,2], ...] is not).
Output is a list of moves of the commutator. All moves must be capital letters in the set
UDLRFBMES, with an optional prime
' or double move
[[F U R], [D B]] = F U R D B R' U' F' B' D' [[F' U2 R], [D B2]] = F' U2 R D B2 R' U2 F B2 D' [[U F' R2 F' R' F R F2 U' F R2], [F U2 F' U2 F2]] = U F' R2 F' R' F R F2 U' F R2 F U2 F' U2 F2 R2 F' U F2 R' F' R F R2 F U' F2 U2 F U2 F' [[M2 E2 S2], [B2 D2 F2]] = M2 E2 S2 B2 D2 F2 S2 E2 M2 F2 D2 B2 [[F], [B]] = F B F' B' [[U], [U]] = U U U' U'