Petrea Corneliu Ştefan >
CM-Permutation-0.94 >
CM::Rubik

Module Version: 0.94
CM::Rubik - Rubik's cube

version 0.94

The Rubik's cube is known primarily as a toy puzzle, which has associated the Rubik's cube group. Its generators are the permutations that correspond to clockwise 90 degrees rotations of each of its faces,let's call these: F R B L D U. These are permutations of the set {1..54} if we consider the centers of the faces also(although these are fixed points under the permutations).

The order of the group is 43_252_003_274_489_856_000 , yeah, that's :

Forty-three quintillion two hundred fifty-two quadrillion three trillion two hundred seventy-four billion four hundred eighty-nine million eight hundred fifty-six thousand. But at least it's not infinite right ? :)

There's also a simulator of Rubik's cube written using OpenGL and Perl, using CM::Permutation and CM::Rubik in order to implement the logic of the rotations:

This will give you the permutation which results from multiplying the sequence of transformations in the string. It returns a CM::Permutation object. OBS: you can also find the order(the number of times you make those moves until the cube returns to the position before you started them) using the order() method on the result, so for example:

my $r = CM::Rubik->new; print $r->comb('FURBL'); 60

To understand where the permutations came from I used the following unfolded version of the cube( also called net ), the numbers are labels for the faces of the cubies:

.----|-----|----. |37 |38 |39 | | | | | |----|-----|----| |40 |41 |42 | <= Back Left | | | | || |----|-----|----| \/ |43 |44 |45 | | | | | /\----|-----|----/\ .----|-----|----\/----|-----|----\/----|-----|----\/----|-----|----. |48 |51 |54 || | | ||36 |33 |30 ||18 |15 |12 | | | | ||21 |24 |27 || | | || | | | |----|-----|----||----|-----|----||----|-----|----||----|-----|----| |47 |50 |53 ||20 |23 |26 ||35 |32 |29 ||17 |14 |11 | <=== Down | | | || | | || | | || | | | |----|-----|----||----|-----|----||----|-----|----||----|-----|----| |46 |49 |52 || | | ||34 |31 |28 ||16 |13 |10 | | | | ||19 |22 |25 || | | || | | | .----|-----|----/\----|-----|----/\----|-----|----/\----|-----|----. \/----|-----|----\/ _// |7 |8 |9 | /\ / /| | | | | || / / / |----|-----|----| Right / |4 |5 |6 | / | | | | <== Front / |----|-----|----| Up |1 |2 |3 | | | | | .----|-----|----.

syntax highlighting: