Back in the day, I used to post math puzzles, similar to how I post origami today. Today I’m revisiting a problem that I never fully solved.
Problem statement: There is a square patch of grass, with sides of unit length. Using the shortest length of fence, block all straight paths that cut across the grass.
I did not create this puzzle, but I am not sure of its original source. The riddle once appeared on the (now defunct) wu : riddles website, under the title “Samwise and Gandalf”. In this version of the puzzle, Lord Sauron has an underground telephone line that cuts a straight line somewhere through a square plot of land. Samwise doesn’t know where it is, so he intends to uncover it by digging up the perimeter. But Gandalf tells him that there is a more efficient solution. What’s the best Sam can do?
The impressive thing about this puzzle is that you can go through many iterations of finding better and better solutions. Afterwards, we’ll consider a hexagonal patch of grass, and other shapes.
1. Perimeter solutions
Now the first solution you might think of, is to fence off the perimeter of the square. This solution has length 4. But you can do one better if you only fence off 3 of the sides. This solution has length 3.

What if we only fenced off two of the sides? You can block all horizontal paths, and all vertical paths. However paths can also cut diagonally across the square. In fact, some paths simply skim the corner of the square. We can conclude that any solution must have fences that extend to each corner of the square.
2. Internal fencing
Okay, so we want the fencing to reach each of the four corners. You don’t need it to go along the perimeter. Why not put fencing that extends from the center to each of the corners? This solution has length 2*sqrt(2) ≈ 2.828
The solution with internal fencing outperforms the solution with perimeter fencing. But surprisingly, you can do even better by mixing internal fencing and perimeter fencing. This leads to a solution with length 2+sqrt(2)/2 ≈ 2.707

3. The 120 degree rule
Let’s import some concepts from advanced mathematics. There’s something called a “minimal surface”, which is very complicated, and yet easily recognizable. It’s basically the math of soap bubbles. You may not understand why thin soap films behave the way they do, but you have a general idea of what they look like. (References: Wikipedia, video.)
The physical law that governs soap films is surface tension. Basically, soap bubbles prefer to minimize their own surface area. When the surface area is minimized, we call it a “minimal surface”.
What we’re doing with fencing is similar. We’re trying to minimize the length of fencing. And fortunately, the fences are simpler than soap bubbles, because we’re only in 2 dimensions instead of 3.
Soap bubbles obey a set of rules called Plateau’s Laws. Among other things, soap films always meet in threes at an angle of 120 degrees. Plateau’s laws were originally based on empirical observation, and are very difficult to prove. But we don’t need to prove it, we’ll just borrow the rule for our fencing problem. If multiple fences meet, we’ll say that they must meet in threes at an angle of 120 degrees.
Let’s try applying it to our previous solutions.

So the best solution I know of has length ~2.639. I’d say this solution is pretty cursed, but it’s only getting more cursed from here.
4. The hexagon problem
So let’s imagine that the patch of grass is a regular hexagon rather than a square. Sides are still of unit length.
We can apply some of the same ideas we applied to the square. First, connect a few of the corners, following the 120 degree rule. Then draw additional fences from the remaining corners.
But which corners do we start with? Here are several different possibilities:

(Aside: The math here gets quite annoying, and how lucky for you that I’m doing the math for you. I make heavy use of the inscribed angle theorem to get the 120 degree angles right. Then I determine the coordinates of each internal point by solving a quadratic equation. Not sure if that’s the cleanest method, but it gets the job done. It’s possible I made a mistake somewhere. If you get a kick out of doing geometry, feel free to check my math.)
When I originally posed this problem on my blog in 2013, my best solution was 4.464. I only recently found the better solution, at 4.366! I’m very pleased by this, and it’s what motivated me to write about it. But I wouldn’t be surprised if you can do even better.
5. The pentagon problem
Now let’s do a regular pentagon (with sides of unit length). Here are several different solutions I checked.

The solution I found in 2013 was 3.544, but now I found a better solution at 3.528.
Based on the best solutions so far, it seems like there’s a bit of a procedure to it.
- Fence off part of the perimeter, connecting three(?) adjacent corners.
- Apply the 120 degree rule.
- These fences block off a section of the grass, so let’s gray out that section of our diagram.
- One by one, for each of the remaining corners, draw a fence from the corner to the nearest point of the grayed-out section. Then, expand the grayed-out section.

But maybe you can do better than that.
6. Extensions beyond
So naturally the next thing to do is a heptagon. The procedure I’ve laid out doesn’t really work anymore, because a heptagon has angles wider than 120 degrees.
But I thought doing the math for a heptagon sounded annoying, so I skipped straight to infinity. If you take the limit of the regular n-gon, that’s a circle. So what if the grass is in the shape of a circle with unit radius?
Earlier, we said that the fence must reach every corner of the polygon. But for a circle, doesn’t that mean the fence has to hit every point on the circle’s circumference? So the length is 2pi≈6.283. Is there any way to do better?
Here’s a better solution. Start with a 3-spoke wheel, which grays out a triangle. Then for each of the exposed sections of the circle, draw a line from the midpoint of the outer edge of the circle to the triangle. This grays out a hexagon. Now draw more lines from the outer edge to the hexagon. Now draw more lines from the outer edge to the 12-gon. Repeat to infinity. The result looks like a fractal clock. Based on my estimate, the total length of the fence converges to around 6.124.

We can get a bit more creative. The rules never said the fence needs to remain inside the grass. So why not go beyond the grass? If we’re talking about paths cutting through the grass, we can extend those paths beyond the grass as well. So we can imagine blocking a path before it even reaches the grass. I think the way I stated the problem, the rules are ambiguous, so we can consider this special rule to be an extension.
Allowing fence to go outside the grass immediately leads to a better solution. Basically we put the circle inside a square, then we apply one of the solutions to the square. For example, here’s a solution with length 6.

So we applied one of the square solutions, and it’s not even the best square solution! So surely we can do better.
So far the best solution I’ve found applies the best hexagon solution, and has a length of 4.826. But I believe there are better solutions out there.

7. Open questions
In summary, there are still many open questions around this problem.
- Can we improve upon my solutions to the square, pentagon, and hexagon?
- What if we allow the fence to go outside the grass, does that enable further improvements?
- What does the general solution look like for a regular n-gon?
- What’s the best we can do for the circle, either allowing or disallowing the fence to go outside the grass?

Leave a Reply