The puzzles in the Tangram app are made by a computer on the spot. This article explains how they are made so that every puzzle is always solvable.

Making the Puzzle from the Answer

The most important idea is to make the answer first, and then turn it into a puzzle.

  1. Make the frame.
  2. Cut the frame into pieces.
  3. Scatter the pieces and line them up in the tray, each turned to a different angle.

If you put the cut-up shapes back, they fill the frame, so every puzzle has at least one solution.

The Frames for Rectangles and Silhouettes

A frame is a collection of triangles (fragments), made by splitting each square of a grid in two along a diagonal. For each square, a random number decides which way the diagonal goes.

  • Rectangles: A rectangle of a size set for each difficulty is used. ★1 uses a 2×2 or 3×2 grid, and ★5 uses a 4×4 or 5×4 grid (whether it is tall or wide is also random).
  • Silhouettes: Starting from a square (a 3×3 grid for ★1, 4×4 for ★2 and ★3, and 5×5 for ★4 and ★5), fragments that face the outside are trimmed away one at a time. The more sides a fragment has facing the outside, the more likely it is to be trimmed, so the shape ends up with many bumps and points. We check each time that the shape does not split in two, and keep going until a set number of fragments remain.
DifficultyRectangles gridSilhouette fragments
★12×2, 3×29 to 11
★23×2, 3×313 to 15
★33×3, 4×316 to 19
★44×3, 4×420 to 23
★54×4, 5×424 to 28

Cutting into Pieces

The frame is cut into the number of stars plus 2 pieces (3 pieces for ★1 up to 7 pieces for ★5).

  1. Start with the hardest fragment to fill among those that remain (the one with the least open space around it).
  2. Add neighboring fragments one at a time to make the piece bigger. Only choose fragments that keep the piece free of dents after they are added.
  3. Aim for a size of about the remaining area divided by the number of pieces left (2 to 8 fragments).
  4. The last piece is everything that remains. If it turns out to be a shape with a dent, the cutting is redone.

Because the cutting starts from the places that are hardest to fill, small fragments are less likely to be left over at the end.

The Shapes in Tangram Mode

In Tangram mode, the pieces are always the classic seven. The frame shape, in contrast, is made by joining the pieces together.

  1. Line up the seven pieces in a shuffled order.
  2. Press the side of the next piece against a side of a piece already placed, lining up the ends exactly.
  3. When all seven are joined, their outline becomes the frame.

First, a random number picks how tangled the shape will be, from five levels. At the levels for compact shapes, placements with a short outline are chosen, and at the tangled levels, placements with a long outline are chosen. That is why the puzzles range from shapes close to a square to shapes with arms and legs sticking out. In about half of the puzzles, the parallelogram is placed in the tray flipped over.

There Is Not Always Just One Solution

There is one solution at the time the puzzle is made, but other arrangements may also fill the frame. The app counts a puzzle as cleared whenever the frame is filled with no gaps and no overlaps, however you arranged the pieces.

For the rules about piece shapes, see What Is a Polygram?, and for help when you get stuck, see How to Use Hints.