"Every fairy tale needs a good old-fashioned villain." -Moriarty
So finally you are here, at the center of the labyrinth. Are you even thinking about a way of getting out ?
Problem 9
Representation of a Rubik's Cube:
Yellow face is Up
Orange face is Front
Green face is Left
Blue face is Right
Red face is Back
White face is Down
Since the center pieces are fixed, any face rotation wont changes the central pieces.
Now lets take a look at the nomenclature of Rubik's Cube moves:
R= clockwise 90∘rotation of right face.
Ri=anti-clockwise 90∘rotation of right face.
Similarly rest of the moves are illustrated below:
Now you will be given the description of a scrambled Rubik's Cube, your task is to output the list of moves which will solve the Rubik's Cube.
For eg, if the given cube is:
It will be represented as following:
UP
GWYWYYRWW
FRONT
GGRBORYYY
LEFT
YOWRGOOOB
RIGHT
BGRGBBBOO
BACK
GROWRBBRG
DOWN
RBOYWGWYW
Let's say we apply the following moves to the cube:
B B
The move will rotate back face 180∘clockwise, now the cube is:
Input:
There will be 12 lines in input. First line will represent the face name, second line will represent the face color description, third line face name and so on. (see the example given in problem statement)
Output:
First line of output should contain an integer N denoting the number of moves.
Next line of output contains N space separated moves. (List of valid moves : R, Ri, L, Li, B, Bi, D, Di, F, Fi, U, Ui)
Scoring:
This is an approximation problem with relative scoring, you task is to maximize your score in comparison to other contestants.
Based on your output moves, the Rubik's cube given to you will be solved and score will be given.
Algorithm of score calculation:
score=0
for i=1 to 6:
m=count of maximum occurring color on face i
score+=m
if m==9:
score+=4 //bonus score for solving a face
if score==78: //cube solved
score+=12 //bonus score for solving complete cube
score+=200/N //tie breaker for solved cubes, N=number of moves
UP GWYWYYRWW FRONT GGRBORYYY LEFT YOWRGOOOB RIGHT BGRGBBBOO BACK GROWRBBRG DOWN RBOYWGWYW