Guide · Behind the scenes

How our thermometer puzzles are generated

Every puzzle on this site is generated in your browser in a fraction of a second, and every one can be solved by logic alone. Here is exactly how that works.

Updated · 4 min read

Part of the complete guide to thermometer puzzles · guide 5 of 7

The pipeline at a glance

  1. Lay out thermometers. Cut the grid into thermometers: straight runs for the straight style, random bending paths for curved.
  2. Choose a hidden solution. Give every thermometer a random fill level, biased toward the middle so lines are neither empty nor full too often.
  3. Count the clues. Count mercury cells in each row and column.
  4. Check with logic. Run a solver that only uses deductions a person could make.
  5. Fix if needed. If logic gets stuck, reveal the cell that unlocks the most, and repeat.
  6. Tidy up. Remove any revealed cells that turned out not to be needed.

1. Laying out the thermometers

The generator visits the cells in random order. From each unused cell it grows a thermometer to a random target length: in a straight line for the straight style, or by a random walk that prefers to turn for the curved style. Maximum lengths grow with the grid, from 4 cells on a 4×4 up to 8 or 9 on the largest boards. Leftover single cells are attached to a neighbouring thermometer's end where the shape allows it. Finally, each thermometer's bulb is put at a random end.

2–3. A hidden solution and its clues

Each thermometer gets a fill level. The level is drawn as the average of two random numbers, which favours middling fills over empty or full ones and makes for more interesting lines. The row and column clues are then simply counted from this hidden solution, so a valid solution always exists. Because each thermometer has only L + 1 possible levels, the search space is far smaller than it looks (see the math of thermometer puzzles).

4. The logic check

A valid solution isn't enough: the clues must pin it down uniquely, and a person must be able to find it without guessing. So the generator runs a logic-only solver that uses exactly the reasoning taught in our lessons:

  • Bounds propagation: the squeeze and ceiling applied to every line, repeatedly, together with flow along tubes.
  • One-step lookahead: if a thermometer's lowest or highest remaining level leads straight to a broken line, that level is ruled out.

If this solver decides every cell, the puzzle has exactly one solution, and that solution can be reached by logic alone. This is a stronger guarantee than uniqueness by itself, and it is what makes the puzzles suitable for teaching step-by-step reasoning.

5–6. Pre-filled cells, chosen carefully

On small grids the generator simply tries new layouts until one passes the logic check on its own, so 100% of 4×4 and 100% of 6×6 puzzles in our sample had no pre-filled cells at all. On large grids that would take too long, so the generator reveals cells instead:

  1. It lists candidate cells at the boundary of each undecided thermometer's hidden fill level.
  2. It tests several candidates and keeps the one that lets the solver decide the most additional cells.
  3. It repeats until the board is fully decided.
  4. Finally, it tries removing each revealed cell. If the puzzle is still fully solvable without it, the cell is dropped.
GridPre-filled cells (avg, straight)Pre-filled cells (avg, curved)Average generation time
4×40 of 160 of 16a few milliseconds
6×60 of 360 of 36a few milliseconds
8×84 of 641 of 64a few milliseconds
10×108 of 1006 of 100well under a second
12×1213 of 1447 of 144well under a second
15×1529 of 22518 of 225well under a second

Measured on 8 puzzles per size. Times vary with your device.

In the game, revealed cells are shown on a tinted background and can't be changed. Cells that follow directly from them (mercury back to the bulb, air on to the tip) are filled in for you to keep the board readable.

Puzzle IDs and the daily puzzle

Every random choice comes from a seeded random number generator. The puzzle ID is that seed, so the size, style and ID together always rebuild the same grid. That makes share links and printed puzzle IDs work. The daily puzzle uses a seed derived from the date, so every player gets the same grid that day.

How we test it

Besides the logic check built into every puzzle, we verify batches of generated puzzles with an independent exhaustive solver that tries every possible combination of fill levels. In our latest run of 600 puzzles, covering every size and both styles, every puzzle had exactly one solution, was fully solvable by logic alone, and was rebuilt identically from its ID.

Questions

Are puzzles made by hand?
No. They are generated by an algorithm, but with strict quality rules: each one must be solvable by logic alone, with a single solution, before you ever see it.
Can two people get the same puzzle?
Yes. The puzzle ID is a seed for the generator, so the same size, style and ID always give the same grid. That is how share links and the daily puzzle work.
Is my puzzle generated on a server?
No. Generation runs in your browser in a background thread, so it works offline once the page has loaded.

Play a generated puzzle

Every puzzle has a shareable ID.

Play now →