hp
toc

Foam Cube Puzzle

2018-12-29, post № 209

programming, Python, #brute-force, #solver

After having solved the puzzle shown below a few times by combining six foam pieces to construct a hollow cube, I wondered if it had a unique solution. A simple brute-force search reveals it does.
Source code: foam-cube-puzzle.py

foam-cube-puzzle.jpg
All six foam pieces.

As a first step, I digitalized all pieces seen above. Having an internal representation, I wrote a script which tries all possible rotations and reflections (as three-dimensional rotations can imply two-dimensional reflection) to try and construct a three-dimensional cube from the given pieces. Using short-circuit evaluation to not bother with already impossible solutions, the search space is narrow enough to not require any considerable computing time. The resulting unique solution modulo rotation is shown above; the top face is placed on the bottom right.

Jonathan Frech's blog; built 2024/03/18 18:45:40 CET