GenerateRandomSearch

Tents and Trees Puzzle Generator

Pitch one tent for every tree, directly beside its own tree, with no two tents touching — not even diagonally. The row and column totals tell you how many tents go where. The subtlety is the word *own*: it is not enough for every tent to sit next to some tree, because the tents and trees must pair up one-to-one, and a layout can satisfy every total while making that pairing impossible.

What this generator does

Places tents first, never adjacent to one another, and gives each its own tree in a neighbouring cell. Row and column totals are read off the finished layout, and the puzzle is published only when solving from those totals yields exactly one arrangement — with the tree-to-tent pairing confirmed to be a perfect matching rather than merely plausible.

How to use this tool

  1. Choose a grid size and generate a puzzle.
  2. Pitch one tent per tree, directly above, below, left or right of it.
  3. Keep the row and column totals exact, and never let two tents touch.
  4. Check that each tree can claim a tent of its own — that is the rule most people miss.

Understanding the controls

Grid size
Between 4 and 8. The number of trees scales with the grid, at roughly one for every six cells.
Show the answer
Places the tents on the grid. Hidden by default so the puzzle can be printed or shared unsolved.
Seed
Any word reproduces exactly the same trees, totals and solution.

Common use cases

  • Printable tents-and-trees puzzles for a puzzle page or a quiet activity
  • Teaching matching as a constraint, in a form that needs no graph theory to enjoy
  • Practising the row-and-column counting deductions the puzzle rewards
  • Test instances for a tents solver
  • Setting the same puzzle for several people from one seed

How this generator works

The solver walks the grid cell by cell, either pitching a tent or skipping, pruned by the row and column totals still outstanding and by the rule that no tent may touch another. A candidate layout is accepted only if a perfect matching exists between trees and tents — computed with augmenting paths, the same method used for assignment problems — because counting adjacency is not the same as pairing everything up.

Randomness and fairness

The tents, trees and therefore the totals are random. A seed reproduces the same puzzle exactly and is therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator is used.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Square grids from 4x4 to 8x8.
  • The tree count is derived from the grid size rather than chosen directly.
  • Difficulty is not graded, and a sparse grid is not always the easier one.
  • Occasionally no uniquely solvable layout turns up and the tool asks you to generate again.
  • Puzzles are not stored between visits; seed one you want again.

Privacy and your data

Everything — the layout, the totals and the matching check — happens in your browser. No part of the puzzle or your seed is transmitted or stored.