One-Stroke Puzzles and Euler Paths: The Königsberg Bridges and the Odd-Vertex Rule
"Draw this without lifting your pencil or going over any line twice." Most of us met this challenge as kids, usually with a little house shape on a napkin. It has a precise answer: a quick count tells you whether a drawing can be done at all and, if it can, where you have to start.
The seven bridges of Königsberg
The Prussian city of Königsberg (today Kaliningrad) sat on the river Pregel. Its land was split into four parts: two riverbanks, an island in the middle and a second piece of land between two branches of the river. Seven bridges joined them. Locals wondered whether you could take a walk that crossed every bridge exactly once.
In 1736 the Swiss mathematician Leonhard Euler showed that no such walk exists. His argument ignored almost everything about the city. All that mattered was which pieces of land were connected and by how many bridges. Today we'd draw each piece of land as a dot (a vertex) and each bridge as a line (an edge). That picture is a graph, and Euler's argument is often called the beginning of graph theory.
The odd-vertex rule
The degree of a vertex is the number of lines that meet there. Euler's insight was about what happens in the middle of a walk. Every time you pass through a point, you arrive on one line and leave on another, which uses up two lines. A point you only pass through therefore needs an even number of lines. The only places that can have an odd number are where the walk starts and where it ends.
That gives a rule you can check in seconds for any connected drawing:
- 0 odd vertices: it can be drawn in one stroke, starting anywhere, and you'll finish where you began. This is called an Euler circuit.
- 2 odd vertices: it can be drawn in one stroke, but you must start at one odd vertex and finish at the other. This is called an Euler path.
- More than 2 odd vertices: it can't be drawn in one stroke, however clever you are.
You'll never find exactly one odd vertex. Each line has two ends, so the degrees always add up to an even number, and the odd ones must come in pairs. Euler stated the condition. The full proof that the even cases always work was published by Carl Hierholzer in 1873.
Now apply the rule to Königsberg. The island had five bridges and each of the other three pieces of land had three. That's four odd vertices, two more than the rule allows, so the walk is impossible.
Worked example: the little house
Take the classic drawing: a square with both diagonals and a triangular roof on top. Count the degrees. The roof peak has 2 lines. The two upper corners of the square each have 4 (a wall, the top edge, a diagonal and a roof line). The center where the diagonals cross has 4. The two bottom corners each have 3 (a wall, the floor and a diagonal). Exactly two odd vertices means it can be drawn, but only if you start at one bottom corner and finish at the other. Start at the roof and you'll always get stuck with a line left over.
A simple method for drawing it
- Count degrees and find the odd vertices. If there are two, start at one of them.
- At each step, choose any unused line, but don't use a line that would cut the remaining lines into two separate pieces unless it's your only choice.
- Keep going until every line is used. If you followed step 2, you'll end at the other odd vertex.
Step 2 is known as Fleury's rule.
Applying the idea to One Stroke Paint
In One Stroke Paint you drag a paint roller from the marked start through every cell of a shape in one continuous stroke, without crossing a painted cell. Here's an honest warning: this is a close cousin of Euler's problem, not the same problem. Euler's rule is about using every line once. Our game asks you to visit every cell once. Mathematicians call that a Hamiltonian path, and there's no quick counting rule that settles it. The degree idea still carries over, though, and it's the most useful tool you have.
Cells with only one way in are endpoints
Think of each cell as a vertex and each shared side as a line. A cell with only one neighbor in the shape, like the tip of a narrow spike, can't be passed through. You'd enter and have nowhere to go. So it has to be where the stroke ends. Since the start is fixed, a shape can have at most one such tip apart from the start cell, and that tip is your finish. Plan your route backward from it.
Watch degrees change as you paint
The same check applies during play. Each painted cell removes options from its neighbors. After each move, look at the unpainted cells around your path. If one is left with only a single unpainted neighbor, it has become a forced endpoint. If two cells are in that state at once, at least one will be stranded. The game shows "Dead end!" when your roller has no way forward, and may nudge you with "Stuck? Undo or hint" when the stroke can no longer cover everything. Spotting the second forced endpoint yourself, a move or two earlier, is the real skill.
Checkerboard counting
Color the grid like a chessboard. Every step moves you to the other color, so a full stroke alternates colors. If the shape has one more cell of one color than the other, the stroke must start and finish on the majority color. That's a quick way to rule out half the candidate finishing cells.
Undo steps back one cell, and dragging back over your last cell does the same. The hint draws the next few cells of a working route from where you are.
Applying the idea to Mow The Grass
Mow The Grass works differently. You swipe, and the mower slides until it hits a hedge, cutting every cell it crosses. You're allowed to cross cut grass again, and the goal is to cut everything, ideally within the par shown at the top. This is much closer to Euler's world. The places where the mower can stop act like vertices, and each straight run between them is a line you need to cover at least once.
Euler's reasoning explains the game's own tip, "Leave the dead-end pocket for last." A pocket with only one way in is like a vertex of degree 1. If you go in early, you must swipe back out along the same lane, which costs an extra swipe. If you make it the place you finish, that cost disappears. The same goes for any stopping point with an odd number of useful lanes. Every such spot that isn't your start or finish forces you to repeat a lane somewhere. Fewer repeats means fewer swipes, and that's how you beat par.
Some swipes are also one-way. Once you slide into certain spots you can't slide straight back. Before a big swipe, check that you'll be able to get out again, and use undo freely when you can't.