# Magnetic cubes puzzle: In theory

Sat 20 January 2018
Tagged: puzzle

I had an idea for a puzzle. Imagine 27 small cubes. Put a magnet on each face of each cube, with variation as to whether North or South is facing outwards. Now try to assemble the cubes into a 3x3x3 "cube of cubes".

To make the puzzle a little more tractable, we can colour the faces of the 27 individual cubes to tell whether they are North or South. E.g. red is North and green is South.

(Update 2018-01-23: Thanks Jez for supplying neater artwork than I managed on my own, all of these diagrams are his).

And to make it a bit more interesting we can stipulate that each of the 3x3 outer faces of the 3x3x3 cube of cubes must have a consistent colour.

Or perhaps a checkerboard pattern.

## Cube Types

Since the polarity of the magnets is fixed, not all cubes are equivalent. For example, a cube that has 2 faces with North poles facing outwards is clearly different from a cube that has 3 faces with North poles facing outwards.

A cube has 6 faces, and each face is in 1 of 2 states (North or South), so there are 26=64 different configurations of a cube. However, many of these configurations are rotational symmetries of one another. For example, the 64 figure includes 6 different cubes that have 1 North face and 5 South faces, but in real life these are equivalent as you can simply rotate the cube.

It turns out there are only 10 distinct configurations of the cube that are not rotational symmetries of one another, which I've labelled as follows:

LabelDescription
6N6 North faces
6S6 South faces
1N1 North face, 5 South faces
1S1 South face, 5 North faces
3R3 North faces, 3 South faces. All of the North faces are adjacent to each other, and all of the South faces are adjacent to each other
3C3 North faces, 3 South faces. Not all of the faces of the same type are adjacent
2Na2 North faces, 4 South faces. The North faces are adjacent to each other
2No2 North faces, 4 South faces. The North faces are opposite each other
2Sa4 North faces, 2 South faces. The South faces are adjacent to each other
2So4 North faces, 2 South faces. The South faces are opposite each other

Mostly self-explanatory, but the difference between 3R and 3C deserves a diagram. The R and C come from "3 in a ring" and "3 in a cup". Not that that makes any more sense.

Here's 3R:

and here's 3C:

Hopefully you can visualise what that would be like in a 3D cube. Ideally I would have made an animation of a 3D cube rotating, showing all 6 sides. You'll notice that in 3R all of the red faces touch each other and all of the green faces touch each other, whereas in 3C only 1 red face touches both of the other 2, and only 1 green face touches both of the other 2.

## Cube Sets

We need to make sure to pick a set of cubes that can actually fit together to form a 3x3x3. We can trivially do this by choosing 27 3R cubes, and then assemble every single cube in the same orientation, with the South faces pointing one way and the North faces pointing the other way, but that doesn't make for a very interesting puzzle.

Coming up with a good cube set is a puzzle all of its own. Ideally we'd have near-equal numbers of each cube type.

I wrote a C program to search for sets of cubes that can form a 3x3x3 cube with consistent colours on the faces, and I eventually found this solution, which is as close to "near-equal numbers of each cube type" as it is possible to get:

2x 6N
2x 6S
2x 3R
3x all the rest

Happily, this cube set can be assembled into both the 3C and 3R configurations of the consistent-faces pattern. (I checked with the C program). That's sure to present endless hours of fun...

I intend to 3D print a physical version of this puzzle (now done, read about it here). I suspect it might be extremely difficult to solve. It doesn't sound too hard (it's just 27 cubes, how hard could it be?), but I've been running an exhaustive search for about a day and have so far found 55 million different solutions for assembling the cube set specified above into a 3x3x3 cube with consistent face colours. I have no idea how many solutions are left to find. The number of ways to combine these 27 cubes is almost unimaginably large.

A 3x3x3 cube has 27! permutations, which is already about 1028. On top of that, each cube can be rotated into 24 different orientations. So even after you've picked one of the 1028 ways to arrange the cubes in space, you have 2427 = 1.8*1037 different ways to actually assemble it, before you find out whether all of your North and South poles line up. Which they probably don't. (Although, again, rotational symmetry cuts down on this number quite substantially).

I don't even know if it'll be possible for a human to solve it without looking at an answer generated by a computer.

We'll find out how hard it really is after I've managed to assemble a real-life version of the puzzle. Incidentally, I have found that to be harder than it sounds as well. Magnets tend to stick together in places you don't want them to stick together, and repel in places you don't want them to repel.