Calculating the Permutations of 4D Magic Cubes
by Eric Balandraud

This paper details the process of coounting the exact number of unique positions that 4D magic cubes of varying edge lengths are reachable from their pristine positions.

There are four types of hyper-cubies: those with 1, 2, 3, or 4 hyper-stickers. We'll refer them here as 1-colored, 2-colored, etc.

3x3x3x3 - i.e. the normal 4D cube with 3 stickers along each edge

For the 3x3x3x3, we can count
• 16 4-colored,
• 32 3-colored, and
• 24 2-colored
• the 8 1-colored elements are immobile and will allow us to locate the position of every other element.

There are two steps to this process. The first one consists of counting the possible positions the cube can be constructed with regardless of positions that are unreachable from the pristine cube. The second step factors out the unreachable positions. Not all the permutations of the 24 2-colored and the 32 3-colored are possible. Only the permutations that have the same parity on the 2-colored and the 3-colored. To check that, it is enough to consider the basic moves of one face. So the number of positions reachable by just the 2-colored pieces is

(24!x32!)/2
All the even permutations of the 4-colored, and the odd ones are impossible, It can be checked on the basic moves, so we count
16!/2
The second step, now that the maximum number of positions are determined, notice that the 2-colored pieces can have two positions on one place, but the
position of the last one is fully determined by the positions of the 23 others, giving
2^23
Every 3-colored can have 3! positions on one place, except for the last one, which can only have 3 positions, giving
(3!)^31 x 3
Finally, the 4-colored, can have 4!/2 positions on one place, except for the last one, which can have only 4 position giving
(4!/2)^15 x 4
All these counts, are independant of each other so the positions of the 3x3x3x3 is the product of all thiese numbers. Therefore the number of reachable positions for the 3x3x3x3 is exactly
(24!x32!)/2 x 16!/2 x 2^23 x (3!)^31 x 3 x (4!/2)^15 x 4
whose decimal expansion is
1 756 772 880 709 135 843 168 526
079 081 025 059 614 484 630 149
557 651 477 156 021 733 236 798
970 168 550 600 274 887 650 082
354 207 129 600 000 000 000 000
or aproximately, 1.7 x 10^120.
4x4x4x4
The 4x4x4x4 has:
• 16 4-colored,
• 64 3-colored,
• 96 2-colored, and
• 64 1-colored
• One additional subtility with the 4x4x4x4 is that there aren't any pieces at the 2D face centers from which to orient our calculations. we therefore need to fix an element to locate all the others, let's fix a 4-colored (it can also be done with a 3-colored).

The even permutations of the 4 colored are possible, so

(15!/2)
And they can have 4!/2 positions but the last, only 4, so
((4!/2)^14)*4
Note that we have fix one of them, so it differs from the counts of the 3x3x3x3.

This time, all the permutations are even for the 3-colored, so

64!/2
(Note that on the 4x4x4, the 2-colored accepts odd permitations)

The 3-colored have 3 positions, on a place, and the last is fully determined by the 63 preseeding , so
3^63
Note that this differs from the 3x3x3x3, and that two 3-colored that have identical colors can't be in the same position and orientation.

The 2-colored accept only even permutations, but as they come in indistinguisable pairs, we count only the visually
different positions, giving

(96!/2)/((4!)^24/2)  =  96!/((4!)^24)
or 2^95, because the position of the last is determined by the others.

The same problem appears for the visually different positions
of the 1-colored, so

(64!/2)/((8!)^8/2)
giving a grand total of
(15!/2)*((4!/2)^14)*4*(64!/2)*(3^63)*(96!/2)/((4!)^24/2)*(2^95)*(64!/2)/((8!)^8/2)
whose decimal expansion is

130 465 639 524 605 309 368 634 620 044
528 122 859 025 488 438 611 959 323 482 221 544 701 493 566
589 669 139 598 204 956 926 940 147 059 366 252 849 247 482
898 636 104 705 417 194 760 866 897 307 590 845 202 461 293
100 468 293 214 262 958 591 194 739 437 727 430 945 469 384
490 361 714 647 847 550 801 897 750 293 894 453 665 815 572
829 257 758 907 425 128 919 808 862 616 259 604 997 210 112
000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

or aproximately 1.3 x 10^334

You can verify this by fixing one of the 3-colored at the beginnig yielding a different formula, but the same result.

5x5x5x5

The 5x5x5x5 has there different families of 1-colored, 2-colored and 3-colored:
• 1-colored:
• 1 group of 48
1 group of 96
1 group of 64
• 2-colored:
• 1 group of 24
1 group of 96
1 group of 96
• 3-colored:
• 1 group of 32
1 group of 64
• 4-colored:
• 1 group of 16
for a grand total of
(48!)/((6!)^8)*(96!)/((12!)^8)*(64!)/((8!)^8)*((24!*32!)/2)*((3!)^31)*(2^23)*(64!/2)*(3^63)*(16!)*((4!/2)^15)*4*(96!)/((4!)^24)*(2^95)*(96!)/((4!)^24)*(2^95);
whose decimal expansion is
82 438 037 949 266 001 798 818 537 185 591 872 622 513
110 723 064 887 446 896 829 783 759 216 987 747 133 338 824 870 722 761 820 399
091 803 906 672 200 562 788 191 831 782 678 757 916 210 500 720 119 109 924 738
176 584 565 957 060 359 083 845 305 523 104 279 597 706 831 282 623 377 308 298
270 256 110 577 915 550 842 311 947 852 455 908 640 926 513 887 950 693 259 734
488 795 516 741 718 855 632 012 409 017 950 565 283 705 637 693 567 551 399 451
022 890 300 760 696 806 001 691 690 503 354 312 640 767 127 338 809 808 328 091
810 728 167 611 236 202 648 298 979 969 629 944 753 096 301 122 250 183 937 655
748 970 939 083 829 108 821 970 975 167 712 732 490 661 498 153 951 649 064 753
809 644 951 943 686 550 000 978 275 868 933 342 691 504 813 788 347 064 370 621
775 923 549 337 026 399 778 184 629 950 873 600 000 000 000 000 000 000 000 000
000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
or 8.2 x 10^700 Quite a number!