How to get all possible rotations of the cube, represented by matrix with data? Let's say I have a cube consists of 3x3x3 smaller cubes like a Rubik's cube, but each smaller cubes have a solid color (Well, it's not a Rubik's cube because rotation of individual elements doesn't matter, but let's name it Rubik's cube):

Each of the cubes have a number 0-26, starting from bottom:

Let's say that you have a [0-26] matrix with all 27 colors.
So I've made a special pattern:
 2,  5,  8,  1,  4,  7,  0,  3,  6,
11, 14, 17, 10, 13, 16,  9, 12, 15,
20, 23, 26, 19, 22, 25, 18, 21, 24

On each iteration, I get color from the cube with number from this pattern. For example, for cube #0 I get the first digit from the pattern which is "2", so I get color from cube #2. So this pattern applies a transformation as like the Rubik's cube itself is rotated at 90 degrees. If I make this operation 4 times, the Rubik's cube will rotate 360 degrees and I will get back to the starting point.
To make it clear, this is how it looks like in Python:
map = [ 2,  5,  8,  1,  4,  7,  0,  3,  6,
       11, 14, 17, 10, 13, 16,  9, 12, 15,
       20, 23, 26, 19, 22, 25, 18, 21, 24]
for i in range(0, 27):
    blocks[i] = blocks_orig[map[i]]
blocks_orig= blocks[:]

So my question is: is it possible to make a pattern, which can "Rotate" the Rubik's cube at any possible directions (is it 24 combinations)? And if it not, what is the minimum count of patterns I have to make? Or maybe you know an easier solution for this task?
 A: No, this is not possible. Whichever way you reorient the cube, that movement will be a rotation around some axis. Such a rotation will always leave three of the little cubes fixed (the three cubes that the axis of rotation goes through - the centre and one on either side) so repeating it can never result in all possible reorientations.
The rotations are:

*

*the identity (no movement at all; 1 way, order 1)

*quarter turn rotation around a face (6 ways, order 4)

*half turn around a face (3 ways, order 2)

*rotation around a corner (8 ways, order 3)

*half turn around an edge (6 ways, order 2)

For a total of 1+6+3+8+6=24 rotations.
The 24 rotations of the cube form a group that is isomorphic to the group $S_4$, the group of permutations of 4 items. The 4 items being permuted are the long diagonals of the cube.
It is possible to use only 2 rotations to generate all of them. Simply choose any two rotations that have distinct axes of rotation that are not perpendicular to each other. For example you could combine any face quarter turn with any corner rotation.
