To count number of permutations of a 3x3 cube, we should count permutations due to both the placement and orientation of each type of piece (corners and edges; centers are fixed):
Furthermore, some of these possibilities are not possible. Only even parity cases can occur on the 3x3 cube, cutting the number of ways of distributing the corners and edges in half.
Total number of permutations of a 3x3 cube:
$$ N = 3^{7} \times 2^{11} \times \dfrac{ 8! \times 12! }{ 2 } = 43,252,003,274,489,856,000 \sim 10^{19} $$
or about 43 quintillion permutations.
def factorial(n):
if(n==1):
return 1
else:
return n*factorial(n-1)
print(3**7*2**11*(factorial(8)*factorial(12))/2)
On a 4x4 cube, we use the same technique as the 3x3, counting permutations due to both placement and orientation of each type of piece. Now each face has four corner pieces, four double edges for eight edge pieces, and four corners. Counting:
The grand total, then, is:
$$ T = 3^7 \times 8! \times 24! \times \left( \dfrac{24!}{12!} \right)^2 = 91793597096746925044380089227138852984017051539472384000000000 \sim 10^{61} $$
print(3**7*factorial(8)*factorial(24)*((factorial(24))/(factorial(12)))**2)