• Welcome to the Speedsolving.com, home of the web's largest puzzle community!
    You are currently viewing our forum as a guest which gives you limited access to join discussions and access our other features.

    Registration is fast, simple and absolutely free so please, join our community of 40,000+ people from around the world today!

    If you are already a member, simply login to hide this message and begin participating in the community!

Formula for Calculating Positions of a NxNxN Cube?

G2013

Member
Joined
Jul 8, 2014
Messages
831
Location
the planet
WCA
2013DIPI01
YouTube
Visit Channel
Those are really clear explanations!
Basically, you have to check how many types of pieces are in what you are calculating, determine parities, check permutations and orientations, and do the math.
So megaminx:
Edges: 30
Corners: 20

Corners can be permutated in 20!/2 ways, because you can't switch 2 of them; it must be 3, and orientated in 3^19
Edges can be permutated in 30!/2 ways, for the same reason as corners, and orientated in 2^29

The parity thing can be:
All even => even+even=even, OK
All odd => odd+odd=even, OK

So:

Edges: (30!/2)*2^29
Corners: (20!/2)*3^19

Total: (30!/2)*2^29*(20!*3^19)/2

I hope it is right
 

cmhardw

Premium Member
Joined
Apr 5, 2006
Messages
4,115
Location
Orlando, Florida
WCA
2003HARD01
YouTube
Visit Channel
The parity thing can be:
All even => even+even=even, OK
All odd => odd+odd=even, OK

So:

Edges: (30!/2)*2^29
Corners: (20!/2)*3^19

Total: (30!/2)*2^29*(20!*3^19)/2

I hope it is right

G2013, your calculation is correct but your parity analysis is not (sort of).

You correctly observed that you cannot swap just two corners or just two edges on minx, but then you say:

The parity thing can be:
All even => even+even=even, OK
All odd => odd+odd=even, OK

Here you say that the corners and edges can have odd parity, as long as they both have odd parity.

Which one is the correct one (they say contradictory things)?

Before you answer, remember that your numerical calculation is correct :)

Good job on these calculations, by the way! This kind of cube math is fun, isn't it? :)
 

G2013

Member
Joined
Jul 8, 2014
Messages
831
Location
the planet
WCA
2013DIPI01
YouTube
Visit Channel
The all even is the only correct, because you can switch: 0 corners, 3 corners, 5 corners, etc. So that is 0 swaps, 2 swaps, 4 swaps, respectively.

And thanks for all!
 
Joined
Nov 29, 2008
Messages
214
The closed formulas for the number of positions of the nxnxn are quite nasty and not very intuitive. The following recursive formulas are short and elegant (in my opinion) and give more insight in the construction process.

usual nxnxn:
a(1)=1;
a(2)=7!*3^6 //2x2x2
a(3)=8!*3^7*12!*2^11/2 //3x3x3
a(n)=a(n-2)*24!*(24!/24^6)^(n-3), n>3

subercube nxnxn:
a(1)=1;
a(2)=7!*3^6 //2x2x2
a(3)=8!*3^7*12!*2^11/2*4^6/2 //3x3x3
a(n)=a(n-2)*24!*(24!/2)^(n-3), n>3

a(1), a(2) and a(3) are just the number of positions for the 1x1x1, 2x2x2 and 3x3x3 and need no explanation except eventually the factor 4^6/2 which gives the number of possible orientations of the centers of the supercube 3x3x3.
The following picture demonstrates for example the case n=9.
from7to9.jpg
We take the 7x7x7 cube which has a(n-2)=a(7) positions. When we insert six slices as depicted we get a 9x9x9 and the additional pieces form exactly 7 orbits: one edge orbit (24! positions) and n-3 = 6 center orbits (each with 24!/4!^6 positions for the usual nxnxn and with 24!/2 positions for the supercube). Multiplying all together gives the formula for a(n). That's all.

Edit: Typo in a(2) for the usual case corrected.
 
Last edited:

goodatthis

Member
Joined
Jan 11, 2014
Messages
841
Location
NY
WCA
2014CAVA01
YouTube
Visit Channel
It may seem so, but 96577 = (13)(17)(19)(23).

So the number of positions formula can be written as a product of exponents of all prime numbers between 1 and 23 (inclusive).

That is, the number of positions formula can be written as:
aschWF9.png

O7Ge4N2.png

3ukVRAZ.png

QBWXWQq.png



In addition, I just got that the derivative can be written as:
dwM3OX9.png

So we simply multiply the number of positions formula by this factor to get the rate of change.

EDIT:
Chris, now I know you're being modest! You have taken on some impressive feats yourself.
I'm curious as to the applications of doing calculus with these formulas, are there any particular reasons why one would want to compute the derivative of these formulas?
 
Joined
Nov 29, 2008
Messages
214
In my opinion the derivative is absolutely useless here. I also see no sense to mimic the Mod function by a Sin or Cos function as I have seen in some posts before.
A handy generating function would be nice but I don’t think it exists. Even for much simpler sequences like 2^(n^2) https://oeis.org/A002416 there does not seem to exist one.
For generating functions in general and how to create them I recommend the free to download book generatingfunctionology from H. S. Wilf.
 
Joined
Aug 12, 2013
Messages
5,090
Location
Brazil
SS Competition Results
YouTube
Visit Channel
python3.11 app
save it as .pyw extensions and execute

it breaks with anything greater than 9.
I may try to find a fix later.

1684987174196.png

Python:
import math
import tkinter as tk
from tkinter import messagebox

# Calculate the number of combinations for an even NxNxN cube
def calculate_even_cube(n):
    numerator = math.factorial(7) * (3 ** 6) * ((math.factorial(24)) ** ((n ** 2 - 2 * n) / 4))
    denominator = (math.factorial(4) ** (6 * (((n - 2) ** 2) / 4)))
    result = numerator / denominator
    return result

# Calculate the number of combinations for an odd NxNxN cube
def calculate_odd_cube(n):
    numerator = (math.factorial(8) * (3 ** 7) * math.factorial(12) * (2 ** 10)) * ((math.factorial(24)) ** ((n**2 - 2*n - 3) // 4))
    denominator = (math.factorial(4) ** (6 * ((n**2 - 4*n + 3) // 4)))
    result = numerator / denominator
    return result

def calculate_cases(size):
    if size == 1: return 1
    if size % 2 == 0:
        return calculate_even_cube(size)
    else:
        return calculate_odd_cube(size)

# Calculate the number of permutations for the cube size specified by the user
def calculate_permutations():
    try:
        size = int(entry.get())
        if size <= 0:
            raise ValueError()
      
        permutations = calculate_cases(size)
        messagebox.showinfo("Result", f"The {size}x{size}x{size} cube has {permutations} permutations.")
    except ValueError:
        messagebox.showerror("Error", "Please enter a positive integer value.")
    except Exception as e:
        messagebox.showerror("Error", e)

# Create the main window
window = tk.Tk()
window.title("Combinations Calculator")

# Configure the window size and position
window.geometry("300x200")
window.resizable(False, False)

# Set a background color for the window
window.configure(bg="#f2f2f2")

# Create a label and an entry field for the cube size
label = tk.Label(window, text="Enter the cube size:", font=("Arial", 14), bg="#f2f2f2")
label.pack(pady=10)

entry = tk.Entry(window, font=("Arial", 12))
entry.pack()

# Create a button to calculate the permutations
calculate_button = tk.Button(window, text="Calculate", font=("Arial", 12, "bold"), bg="#4CAF50", fg="white", relief="flat", command=calculate_permutations)
calculate_button.pack(pady=10)

# Start the main event loop
window.mainloop()
 
Top