Your challenge is to output the number of twisted corners given a 2x2 Rubik's Cube scramble.
For the purpose of this challenge, twisted corners are defined as corners where the colour of the top/bottom face before (usually white or yellow) is not facing the top/bottom after the scramble.
Eg. if the cube were to be oriented yellow top/white bottom, then the number of corners where yellow/white isn’t on the top/bottom after the scramble should be returned.
A scrambled cube is represented as a list of moves, where each move is denoted by the letters UDRLFB
corresponding to clockwise turns of the faces: Up, Down, Right, Left, Front, and Back.
You have the option to replace the moves UDRLFB
with a predefined set of constants. You may assume the scramble list is non-empty.
This is code-golf, so the shortest answer wins!
Standard loopholes apply, this loophole in particular is forbidden too.
Test cases
Example gif with scramble "L U U U F" | Top and bottom face after scramble
[In]: R
[Out]: 4
[In]: L U U U F
[Out]: 3
[In]: R R D D D B B U L F
[Out]: 6
[In]: B U U D D F
[Out]: 0
R
makes all the corners on the right side twisted andLLL
does the same to the left side (as it is just an anticlockwise quarter turn of the left face), so all eight corners end up twisted. \$\endgroup\$