Decompose algorithms in commutator notation.
Let
In this repository, we assume that
In mathematics, the free group
It is worth researching since many 3-cycle and 5-cycle algorithms in a Rubik's cube can be decomposed into commutators.
Example 1:
Input: s = "R U R' U'"
Output: "[R,U]"
Example 2:
Input: s = "a b c a' b' c'"
Output: "[a b,c a']"
Explanation: a b + c a' + b' a' + a c' = a b c a' b' c'.
And "[a b,c b]" is also a valid answer.
Example 3:
Input: s = "D F' R U' R' D' R D U R' F R D' R'"
Output: "D:[F' R U' R',D' R D R']"
And "[D F' R U' R' D',R D R' D']" is also a valid answer.
Example 4:
Input: s = "R' F' R D' R D R2 F2 R2 D' R' D R' F' R"
Output: "R' F':[R D' R D R2,F2]"
Example 5:
Input: s = "R U R'"
Output: "Not found."
Constraints:
- s consist of only English letters.