Your challenge is to translate a Cubically cube-dump to the format specified in this challenge.
Input
The input will represent a Rubik's Cube, formatted how Cubically prints its memory cube at the end of every program.
This is a solved cube:
000
000
000
111222333444
111222333444
111222333444
555
555
555
This is a cube scrambled with L2D2L2D2B2R2F2L2D2U2F2UF2U'R2UB2U'L2UB2U'LU'L2U'D'B2U'RBUBF'D'
(Singmaster's notation):
201
501
331
132505224540
512324533442
404513210411
350
254
003
Output
If you already understand this format, hit page down a few times to skip lots of explanation.
The output will represent a Rubik's Cube, formatted how solutions to this challenge take input.
The first 12 values are the edge cubies, and the next eight are the corners. The faces are U(p), D(own), R(ight), L(eft), F(ront), and B(ack). First the cubie that's in the UF position is given, by the color (in UFRDBL notation) that's on top first, and then the other color next, and so on.
This format is a bit confusing, so here's a way to visualize it. This is the solved cube:
That renders the output UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
.
If we were to swap, for example, the red-white edge and the red-blue edge, the visualization would look like this (with no changes to the hidden faces):
That renders the output UR UF UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
(which, btw, is an impossible cube state). Note that the order of the letters in cubies matter:
Above: UR UF UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
Below: RU FU UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
The cube scrambled with L2D2L2D2B2R2F2L2D2U2F2UF2U'R2UB2U'L2UB2U'LU'L2U'D'B2U'RBUBF'D'
creates this cube (only the top, front, and right faces are shown):
Solved: UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
Scrambled: RU LF UB DR DL BL UL FU BD RF BR FD LDF LBD FUL RFD UFR RDB UBL RBU
As you can see in the comparison above and in the visualizations, the blue-red RU
edge of the mixed cube is in the place of the red-white UF
edge of the solved cube. The green-white LF
edge is in the place of the red-blue UR
edge, etc.
Rules
- I/O will be done via any allowed means.
- The output cubies must be delimited by any whitespace character you choose.
- The input will be formatted exactly how it is shown in the challenge, including whitespace.
- Your program may do whatever you like if the inputted cube is unsolvable.
Test cases
- Input -> output:
RU LF UB DR DL BL UL FU BD RF BR FD LDF LBD FUL RFD UFR RDB UBL RBU
- Input -> output:
UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
- Input -> output:
FU DL LB BU RU BR RF DR BD DF LF LU FUL FLD URB BLU RUF DBR BDL RFD
Here's a reference program using parts of Cubically's rubiks.c.
Winner
As this is code-golf, the shortest answer in bytes wins!