Search for Soma Cube Solutions
The Soma cube consists of seven polycubes with three or four small cubes each that can be assembled into a cube. This Demonstration allows you to watch the progress of an exhaustive search to find all solutions. At each step, the next piece is put into one of all possible orientations and a solution is searched recursively. The controls allow you to single-step through the search, advance to the next solution, let it run to completion or start over. The slider allows you to dissect the assembled pieces.
The search generates all solutions that are distinct up to a rotation of the cube as a whole. There are 480 such solutions. The first piece is placed in one of four positions; the remaining pieces are tried in all possible translations and rotations. It turns out that only the first placement of the first piece admits any solutions, due to parity considerations.
The first control triggers a single step of adding another piece or removing one piece when backtracking. The second control runs the animation until a solution is found. It introduces a variable delay after each step. The third control continues the search to completion and introduces delays only when a solution has been found. Clicking a control again stops the animation. The two counters count the number of solutions found and the total number of steps tried.
The natural search algorithm is recursive. To allow single-stepping and maintaining state in the notebook, it was converted into an iterative version.