

Representation The key concept in this implementation of magic hypercubes is representation. There are two inputs to this algorithm:

These inputs determine the internal representation for each cell in the magic hypercube. In particular, each cell is represented by a ntuple:
where each d is an integer in the range 0 through (Row_Size1) and n is the number of dimensions in the magic cube. The algorithm places ntuples into each cell in the hypercube so that each digit appears only once in any hyperrow.
It is easy to prove that this structure represents a magic hypercube: the sum of the individual digits for any hyperrow is always the same: SUM(0:ROW_SIZE1).
Sums of cells within hyperrows will remain identical if you add a constant to each cell. To aid visual representation, I have chosen to set the center cell of the hypercube to zero by subtracting a constant equal to (ROW_SIZE^DIMENSIONS1)/2 from each cell. This illustrates symmetry by matching positive and negative integers in cells that are in symmetric positions with respect to the center cell. It also creates a property wherein the sum of the cells in any hyperrow is equal to zero.
