Whenever you make a move on a Rubik's Cube, there is a reverse move which undoes the first move. Because of this, every algorithm (set of moves) has a reverse algorithm which undoes the first algorithm.
The goal of this challenge is to find the reverse of a given algorithm.
The input consists of an array of individual moves. Each move is a string of length 1 or 2. Of course, you can use whatever input format makes the most sense in your language. Each move consists of the structure
X is an uppercase or lowercase letter.
X, simply replace it with
X2 on the other hand does not get changed.
To create the output, reverse each move, and then reverse the array.
Examples (strings separated by spaces):
D U' =>
S T A C K =>
K' C' A' T' S'
A2 B2 =>
This is code-golf, so the fewest amount of bytes win. Standard loopholes are not allowed.
X1would have been a nice addition to the challenge. \$\endgroup\$
D2R2as a test case... \$\endgroup\$