480 solutions of the Magic magnetic cube puzzle

The magic magnetic cube is a colored variant of the Soma cube puzzle. Let’s solve the puzzle in a browser using JavaScript.

Marian Čaikovski


I recently came across an addictive puzzle for kids — Magic magnetic cube. It is a set of 7 blocks with different shapes and colours that have to be assembled into a cube.

Depending on the vendor the same shapes can be colored differently.

After trying a bit, I eventually manage to assemble the blocks into a cube. But every assembled cube seems different because I assembled them accidentally, rather than consciously. So I wondered how many distinct cubes can be assembled from those 7 blocks.

Furthermore, it seemed to me that the assembled cube had the orange block at a corner. So I additionally wondered if the orange block can be placed in a cube not at a corner.

To answer those two questions that somewhat bothered me, I decided to calculate the possible solutions.

It turns out that 480 unique cubes can be assembled from the building blocks. None of the calculated 480 cubes is a rotation of any other cube from the result set.

Of 480 cubes in 74 the orange block does not form a corner.

The results of my calculations are arrays. It is tough to imagine a colorful cube by looking at numbers. So I visualised them using Three.js. It is a powerful library but I did not spend time on beautifying the output. I only exploited BoxGeometry allowing straightforward visualization of 3D-arrays. You can see the results here https://magneticcube.onrender.com/results.html. The cubes can be rotated using a mouse.

Basically that is it. If you are interested in how I generated the solutions, continue reading below.

Computing magnetic cubes



Marian Čaikovski

Java, JavaScript and SQL developer. Interested in data collection and visualization.