Background
On a Rubik's cube there are 54 moves that you can execute, for example, turn the right face anti-clockwise, or rotate the top face and the horizontal slice twice. To notate any move, each face (or slice) has a letter assigned to it. To move that face clockwise once, you just write the letter on its own, so for the top face it would be U
(for "up"). You can put a '
(pronounced "prime") after the letter to notate moving the face anti-clockwise, or a 2
to turn the face twice. You can see more details on this here.
The Challenge
Your challenge is to take a list of moves which all rotate the same face, and simplify it into one move. For example if the input was R R2
, you'd be turning the right face clockwise once, then twice, which results in the equivalent of R'
— turning the right face anti-clockwise once.
Rules
- If the result doesn't modify the cube, the output should be nothing or a falsey value.
- Input must be taken in the proper notation described above, otherwise, it's up to you.
- You can assume that no move will have a
2
and a'
in it.
Test Cases
R R2 -> R'
L2 L L' L -> L'
u' u2 u2 -> u'
y y' ->
F F' F F F' -> F
E' E2 E E E' -> E2
L2 L L' L
as[2, 1, 3, 1]
(and another inputLLLL
which is ignored) and simply sum them up, mod 4, outputs3
, is this still something "reasonable"? \$\endgroup\$