Problem of the day
Refer to the Sample Input 1 explanation for a better understanding of the operations.
The first line will contain the integer 'T', the number of test cases.
Each test case consists of twenty lines.
The first eighteen lines contain the values of the faces on SudoKube in the order given below
D D D
D D D
D D D
U U U
U U U
U U U
L L L
L L L
L L L
F F F
F F F
F F F
R R R
R R R
R R R
B B B
B B B
B B B
where
D for Down face
U for upper face
L for Left face
F for Front face
R for Right face
B for Back face.
The input contains digits from 1 to 9 instead of letters; letters are displayed for a better understanding of the faces and the expected input format
The nineteenth line will contain ‘Q’, the number of operations to be performed.
The twentieth line contains a sequence of space-delimited moves that need to be performed on the SudoKube
Example 1: D F2 R' U - to understand this please refer to the second example from the Examples section below
Example 2: L2 U B F' D2 R - let's understand how to interpret this set of operations
L2 means rotate the Left side by 180 degrees
U means rotate the Up side by 90 degrees clockwise
B means rotate the Back side by 90 degrees clockwise
F' means rotate the Front side by 90 degrees anticlockwise
D2 means rotate the Down side by 180 degrees
R means rotate the Right side by 90 degrees clockwise
In summary, the first eighteen lines denote the state of the SudoKube, the 19th line denotes the operation to be performed on that state.
For each test case, Print six 3x3 matrices in D, U, L, F, R, B order representing the SudoKube, corresponding to the operations, when performed in the given order.
You don't need to print anything. It has already been taken care of. Just implement the given function. You just have to return an 18x3 matrix after performing all the operations in the given order.
‘T' = 1
Values in SudoKube will be between 1 and 9
1 <= Operations to be performed (‘Q’) <= 20
Time Limit: 1 sec
1
4 7 1
2 8 7
6 3 5
5 8 3
3 1 6
9 4 2
5 2 4
3 7 8
5 1 9
6 1 4
9 4 8
2 5 7
7 9 1
1 9 6
6 2 8
8 6 3
7 2 5
3 9 4
1
F
6 1 7
2 8 7
6 3 5
5 8 3
3 1 6
9 8 4
5 2 4
3 7 7
5 1 1
2 9 6
5 4 1
7 8 4
9 9 1
4 9 6
2 2 8
8 6 3
7 2 5
3 9 4
The Upper Face’s last row after rotation is copied to the first column of the Right Face
The Right Face’s first column after rotation is copied to the first row of the Down Face
The Down Face’s first row after rotation is copied to the last column of the Left Face
The Left Face’s last column after rotation is copied to the last row of the Upper Face.
Similarly, the Front Face is rotated 90 degrees clockwise.
1
4 7 1
2 8 7
6 3 5
5 8 3
3 1 6
9 4 2
5 2 4
3 7 8
5 1 9
6 1 4
9 4 8
2 5 7
8 6 3
7 2 5
3 9 4
7 9 1
1 9 6
6 2 8
6
F F F2 L L’ B
4 7 1
2 8 7
5 3 5
3 5 4
3 1 6
9 4 2
3 2 4
8 7 8
5 1 9
6 1 4
9 4 8
2 5 7
8 6 5
7 2 3
3 9 6
6 1 7
2 9 9
8 6 1