This project was inspired by the Stand-up Maths video Why 2025 is numerically the best year. The puzzle is a visual illustration of the Triangle Number relation that states that the sum of the first \(n\) cubes is equal to the square of the \(n\)-th triangle number (easily proven by induction): \[\sum_{k=1}^{n} k^3 = (\sum_{k=1}^{n} k)^2. \]
While this is necessary for a tiling of the square to exist, it is not sufficient as can be seen in the \(n = 2\) case. A tiling is however guaranteed for all cases above \(n = 7\), so including the trivial case the tiling set is \(n \in \mathbb{N}\setminus[2,7]\).
This static webpage, repo here, provides a front-end for a solver I implemented in C and compiled to WASM with Emscripten. The solver works by descending a decision tree recursively until a solution is found or the puzzle reaches an unsolvable state, where it removes the last tile and places a different one. If no placements are possible, then the starting configuration was unsolvable. This is in essence an exhaustive search of the possibility space, so it is guaranteed to terminate. The choice of which tile to place next, excluding already placed tiles at that position, is random so while the solver is guaranteed to terminate the execution time is not deterministic. Depending on your luck, you could get a solution in seconds or hours or days or more for larger puzzles.
The solver creates many more events than the visualizer can process and in order to keep the page responsive excess events are dropped. This will manifest in the visualizer occasionally de-syncing tile placements and removals.
While the page layout works on mobile, the implemented touch controls for dragging the tiles and the canvas layout-ing itself don't work very well. I don't know how much effort I will invest in making them better though. I do plan on at least improving the solver a bit more in order to detect unsolvable branches sooner.