How to solve a pipe puzzle, from the corners in
· 8 min read · Tyamka team
Solve a pipe puzzle by deduction, from the corners and edges inward. A real 4×4 board worked pass by pass, and what changes when pipes wrap around.
In this article
To solve a pipe puzzle, turn the tiles until every pipe opening meets an opening on the next tile and all the tiles form one network with no loops. Start with the tiles that the border leaves with only one position, then let each settled tile decide its neighbors, and work inward. Below is why a well-made board has exactly one answer, a real 4×4 board solved in three passes, and what changes when the board wraps around its edges. The examples come from Pipes, the pipe puzzle game on this site.
Why a good board has exactly one answer
A pipe puzzle is built backward. Our generator starts at the source, the tile in the middle of the board, and grows a random network from it one link at a time. Each new link joins a tile that is not in the network yet, so no loop can form, and no tile gets more than three openings. A four-way cross is left out because it looks the same in every position, so there would be nothing to turn. When every tile is in, the network is what mathematicians call a spanning tree, n tiles joined by n − 1 links. Then every tile is turned at random, and that is the board you see.
Turning a tile never changes how many openings it has. The 4×4 board below has 16 tiles and 30 openings, exactly enough for 15 links. So if every opening on your board meets another one and you still see a closed loop somewhere, some tiles are cut off from the rest. A loop always means a mistake.
A tree alone does not guarantee one answer. Sometimes a second arrangement of the same tiles also works. Before a board is shown, the game runs a solver that counts the arrangements and stops at two. If it finds two, the tree is thrown away and a new one is grown. So you never have to choose between two right answers.
One answer does not mean an easy one. In 2004 Daniel Král and colleagues proved, in a paper titled "It is tough to be a plumber", that deciding whether a pipe board has any solution is NP-complete, so no shortcut is known that works for every large board.
Start where the board decides for you
On a board without wrapping, no pipe may point off the edge. Here is how many positions each kind of tile has left, by where it sits.
| Tile | In a corner of the board | On an edge | Inside |
|---|---|---|---|
| End, one opening | 2 | 3 | 4 |
| Straight | never there | 1 | 2 |
| Corner piece | 1 | 2 | 4 |
| Three-way | never there | 1 | 4 |
So three kinds of tile are fixed on sight. A corner piece in a corner of the board points inward both ways. A straight on an edge runs along it. A three-way on an edge keeps its flat side to the border. Ends are the weakest clue on their own, but a settled neighbor narrows them fast.
From there, work inward. Every settled tile tells each neighbor whether it needs an opening on the side they share.
One warning about color. In Pipes, tiles linked to the source turn dark, and at the start some are linked by chance. Dark means connected, not correct. On the board below, one of the five dark tiles at the start is in the wrong position.
A board solved step by step
This is the first of the three boards our generator makes for level 2 from seed 7. It is one of the test boards that every version of the game has to rebuild tile for tile, and the picture shows the same board in the game right after Start.

In the tables, ↑ → ↓ ← are ends, and the arrow shows where the single opening points. The other tiles are drawn as they look. The source is the three-way ┤ in row 3, column 3. A question mark is a tile that is not settled yet.
The board as dealt.
| Col 1 | Col 2 | Col 3 | Col 4 | |
|---|---|---|---|---|
| Row 1 | ↓ | → | │ | ┐ |
| Row 2 | ─ | ↑ | ┌ | ┘ |
| Row 3 | │ | ┐ | ┤ | → |
| Row 4 | ┐ | │ | ┤ | └ |
Pass 1, the border. Three corners hold corner pieces, so each has one position. That gives ┐ in the top right, └ in the bottom left and ┘ in the bottom right. The straights on the edges run along them, ─ in row 1, │ twice in column 1 and ─ in row 4. The three-way in row 4 turns its flat side down and becomes ┴. Eight tiles are settled without looking at a single neighbor.
| Col 1 | Col 2 | Col 3 | Col 4 | |
|---|---|---|---|---|
| Row 1 | ? | ? | ─ | ┐ |
| Row 2 | │ | ? | ? | ? |
| Row 3 | │ | ? | ? | ? |
| Row 4 | └ | ─ | ┴ | ┘ |
Pass 2, the rest of the border. The end in the top left corner could open right or down. The straight below it now opens up, so the end opens down. The end in row 1, column 2 sits next to a straight that opens left, so it opens right. In column 4, the corner piece in row 1 opens down, so the corner piece in row 2 must open up, and the only way to do that without pointing off the board is ┘. The end in row 3 has the bottom right corner opening up at it, so it opens down. Three of these four were already right as dealt, but only now is that certain.
| Col 1 | Col 2 | Col 3 | Col 4 | |
|---|---|---|---|---|
| Row 1 | ↓ | → | ─ | ┐ |
| Row 2 | │ | ? | ? | ┘ |
| Row 3 | │ | ? | ? | ↓ |
| Row 4 | └ | ─ | ┴ | ┘ |
Pass 3, the middle. The source has the ┴ below it opening up and the end to its right pointing away, so it must open up, down and left, which is ┤. The corner piece above the source needs an opening down to the source and one to the right, where ┘ opens left, so it is ┌. The corner piece to the left of the source must open right. It cannot open down, because the straight below it runs sideways, and it cannot open left, because the straight in column 1 runs up and down. That leaves └. Finally, the end in row 2, column 2 has └ opening up at it, so it opens down.
| Col 1 | Col 2 | Col 3 | Col 4 | |
|---|---|---|---|---|
| Row 1 | ↓ | → | ─ | ┐ |
| Row 2 | │ | ↓ | ┌ | ┘ |
| Row 3 | │ | └ | ┤ | ↓ |
| Row 4 | └ | ─ | ┴ | ┘ |
Every pipe meets a pipe, all 16 tiles link to the source, and there is no loop. Not one step needed a guess. The game's own solver agrees, it settles this board without trying a single position. Seven of the 16 tiles were in place from the start, but that is no help until the reasoning reaches them.
When pipes wrap around the edge
From level 11, Pipes wraps. A pipe that leaves the right edge comes back on the left, and one that leaves the top comes back at the bottom. Every tile now has four neighbors, so the first pass above has nothing to work with. Here is the solved second board of level 11 from seed 5.
| Col 1 | Col 2 | Col 3 | Col 4 | |
|---|---|---|---|---|
| Row 1 | → | ─ | ┘ | │ |
| Row 2 | → | ┐ | ┌ | ┘ |
| Row 3 | ─ | ┴ | ┤ | → |
| Row 4 | ← | → | ┤ | ┌ |
The top right corner holds an upright straight, and the bottom right corner holds a corner piece pointing right and down, straight off the board. Neither could happen without wrapping. Four pipes cross an edge here, two through the top and two through the right side.
That is why level 11 goes back to a 4×4 grid after the 7×7 boards of levels 8 to 10. On 9 November 2026 we generated every board of levels 2 and 11 for 1,000 seeds, 3,000 boards each. Matching openings to neighbors, applied again and again with nothing else, finished 90.6% of the plain 4×4 boards on its own. It finished none of the wrapping ones. To get 3,000 wrapping boards with one answer, the generator threw away 6,981 trees, against 39 on the plain grid. Wrapping removes the easiest deductions, so the new rule arrives on a small board.
Where to start on a wrapping board.
- Read the opposite edge as the neighbor. Column 4 touches column 1, and row 1 touches row 4.
- Two ends never face each other. Together they would form a tiny piece cut off from the rest.
- Watch for loops that run through the edge. On a 4-wide board, four sideways straights in one row close into a ring.
- When matching runs dry, take the tile with the fewest positions left, try one, and follow the consequences. If they lead to a loop or a cut-off piece, that position is wrong, and you try the next. That is also what the game's solver does.
Pipes on Tyamka
In our pipe puzzle the grid grows from 3×3 on level 1 to 7×7 on levels 8 to 10. Levels 11 to 15 repeat the climb on wrapping grids, from 4×4 back up to 7×7. A level is two or three boards, each with its own time limit, from 40 seconds on level 1 to 150 seconds on levels 8 and 14. When time runs out you lose one of three lives.
A solved board earns 10 points and a speed bonus of up to 10 more, which shrinks to zero at about half the limit. The number of turns does not count, only the time. Levels 1 to 5 are free. The limits are our first guess and have not been tested on players yet.
The same idea of starting at the most constrained spot runs through the other logic games. A maze is a spanning tree too, and the sum puzzle strategy leans on a unique answer in the same way.
Sources
- Tatham S. Net, chapter 3 of the manual for Simon Tatham's Portable Puzzle Collection, distributed under the MIT license. chiark.greenend.org.uk
- Pipes (puzzle). Wikipedia, checked 2026-11-09. en.wikipedia.org)
- Král D., Majerech V., Sgall J., Tichý T., Woeginger G. (2004). It is tough to be a plumber. Theoretical Computer Science, 313(3), 473–484. DOI