What are the possibilities of a $4 \times 4 \times 4$ array that has two $0$s and two $1$s in each line?

85 Views Asked by At

So this is a $4$ by $4$ by $4$ cube consisting of $64$ ($1$ by $1$ by $1$) small cubes, which can have the value of $0$ or $1$. What we call a line here is strictly straight, and not diagonal. So if we look at one side of the cube we have $4 \times 4$ perpendicular lines from each of the small cubes.
This way we can calculate, that the total lines of the cube are $4 \times 4 \times 3$ (4*4 from the 3 different dimensional sides). And out of the $64$ small cubes $32$ have the value $0$, and $32$ have $1$. (Just to make sure everyone understand what i am talking about)

The main question is how many different possibilities are there, where you can't rotate one cube to the other. And how can you generate them mathematically?

Other question maybe: How many are there where it is a different matrix in every aspect (you cant rotate the matrix, swap slabs).

2

There are 2 best solutions below

1
On BEST ANSWER

As the other answer already described, this is straightforward to do with a computer program.

The C# code below uses a pre-defined list of the 6 ways to choose 2 out of 4 bits, which are the valid lines in the cube.

It then takes any 3 of those lines to start making a layer, checks that they are a valid combination so far (there are no columns with 3 bits set), calculates the fourth line of the layer (by taking the XOR of the existing lines so that each column has an even number of bits set), and checks that the fourth line is also a valid line. If so, we have a valid layer.

The next stage does the same but with the layers. So it counts all valid triplets of layers that produce a valid fourth layer.

     ISet<long> lines = new SortedSet<long> { 0b0011, 0b0101, 0b1001, 0b0110, 0b1010, 0b1100 };
     ISet<long> layers = new SortedSet<long>();

     // build layers
     foreach (long l1 in lines)
     foreach (long l2 in lines)
     foreach (long l3 in lines)
        if ((l1 & l2 & l3) == 0)
        {
           long l4 = l1 ^ l2 ^ l3;
           if (lines.Contains(l4))
           {
              long lay = l1 + (l2 << 4) + (l3 << 8) + (l4 << 12);
              layers.Add(lay);
           }
        }

     Console.WriteLine($"{layers.Count} layers");

     long count = 0;
     // build cubes
     foreach (long l1 in layers)
     foreach (long l2 in layers)
     foreach (long l3 in layers)
        if ((l1 & l2 & l3) == 0)
        {
           long l4 = l1 ^ l2 ^ l3;
           if (layers.Contains(l4))
           {
              count ++;
           }
        }

     Console.WriteLine($"{count} cubes");

The result is:

90 layers
51678 cubes

3
On

There are six columns.
Of the $6^3$ ways to fill the first three columns, calculate $2-sum$ to get the 4th column, and check whether it is all 0s and 1s, and sums to 2. You get 90 possible $4×4$ squares.
Of the $90^3$ ways to fill the first three layers, calculate the 4th layer and check whether it is valid.