[Community puzzle] 2×2×2 Rubik’s cube movements


This topic is about the puzzle 2×2×2 Rubik’s cube movements.

Feel free to send your feedback or ask some help here!


At last could apply the knowledge of matrix rotation operators somewhere :slight_smile: Loved this puzzle!


Thank you. :wink:


I think this sentence is missing a verb: “The moves in one single line, for example B’ eventually with dots (for human readability, you can ignore them).”

Can you clarify? Thanks.


It’s in the I/O section, it’s not really expected to be a sentence.

Weirdest part of this sentence (but you can get used to it easily) is the French use of “eventually” to actually mean “possibly”.


OK, edited.


Thanks. I’m francophone, but out of practice. Been living here too long.


I am not able to pass the last validator. I checked my code by printing all 6 faces for each possible movement and everything looks good. I am wondering if I misunderstood something. Hint?



Does your code work if the input contains a dot after F/B/L/R/U/D/2?


Yes. My understanding is that the dot can be ignored. I am able to pass the given test case “R2L2UD’.F2B2UD’” which has a dot in it. I put a dot after one of the 2 and it still passes.


Have you tested/checked your code regarding the moves which do not appear in any of the test cases e.g. F’, B’, L’, U’, D and D2?


EvilGenius008, a tip: what if every single square had a unique id?


Hi. I think I must be misintrepreting the moves.
Would you mind correcting me?

front: turn the entire cube clockwise
back: turn the entire cube clockwise (is this a trick description?)
up: turn the upper half part of the cube clockwise
down: turn the lower half of the cube clockwise
left: turn the left part of the cube upward
right: turn the right part of the cube upward

{any}2: repeat any twice
{any}’: repeat any but in the reverse direction


Nope. Turn the back face clockwise if you look at the cube from the back.


That made me get it! I completely forgot rotations!
Whoops. Thanks! =D


I am having the same problem with the last validator, i have now tried everything that i came to think of, and still haven’t found any errors in my output… do you have a hint if you have solved it by now? :confused:


All tests passed OK during test phase, though all validation tests failed. Why?


It’s easy to mess up the rotation directions, while there are very few testcases. Here are a few more (random) examples to help debugging.












Thanks for the test values. I just received my rubik’s cube 222 ordered 2 days ago as well, I have put stickers on each face of my cube with face name and cube number… And I could find my bug (prime movement was treated similar as non prime movement in cube new position) and added a small code to handle that:

self.moveDict = {“R”: {2: 6, 6: 7, 7: 3, 3: 2},
“L”: {5: 1, 1: 4, 4: 8, 8: 5},
“U”: {1: 5, 5: 6, 6: 2, 2: 1},
“D”: {4: 3, 3: 7, 7: 8, 8: 4},
“F”: {1: 2, 2: 3, 3: 4, 4: 1},
“B”: {7: 6, 6: 5, 5: 8, 8: 7}}
tmpDict = self.moveDict.copy()
for face in tmpDict:
primeFace = “{}’”.format(face)
tab = dict()
for key, value in self.moveDict[face].items():
tab[value] = key
self.moveDict[primeFace] = tab


I believe there is a typo in the last test case: it should be “LB/DB”, not “RB/DB”.
Thanks for providing these btw, they helped me a lot to debug my code.