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.
Part of the complete guide to thermometer puzzles · guide 5 of 7
The pipeline at a glance
- Lay out thermometers. Cut the grid into thermometers: straight runs for the straight style, random bending paths for curved.
- Choose a hidden solution. Give every thermometer a random fill level, biased toward the middle so lines are neither empty nor full too often.
- Count the clues. Count mercury cells in each row and column.
- Check with logic. Run a solver that only uses deductions a person could make.
- Fix if needed. If logic gets stuck, reveal the cell that unlocks the most, and repeat.
- 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:
- It lists candidate cells at the boundary of each undecided thermometer's hidden fill level.
- It tests several candidates and keeps the one that lets the solver decide the most additional cells.
- It repeats until the board is fully decided.
- Finally, it tries removing each revealed cell. If the puzzle is still fully solvable without it, the cell is dropped.
| Grid | Pre-filled cells (avg, straight) | Pre-filled cells (avg, curved) | Average generation time |
|---|---|---|---|
| 4×4 | 0 of 16 | 0 of 16 | a few milliseconds |
| 6×6 | 0 of 36 | 0 of 36 | a few milliseconds |
| 8×8 | 4 of 64 | 1 of 64 | a few milliseconds |
| 10×10 | 8 of 100 | 6 of 100 | well under a second |
| 12×12 | 13 of 144 | 7 of 144 | well under a second |
| 15×15 | 29 of 225 | 18 of 225 | well 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?
Can two people get the same puzzle?
Is my puzzle generated on a server?
Play a generated puzzle
Every puzzle has a shareable ID.