On this page
If you put a spider on one wall of a rectangular room and a fly on the opposite wall, what is the shortest path the spider can crawl to catch its dinner?
Most people picture the spider crawling straight up to the ceiling, walking across, and coming down the other side. But geometry hides a faster, highly counter-intuitive route. This puzzle, known as The spider and the fly problem, is a classic test of spatial reasoning, much like finding vertices and edges on 3D polyhedra.
Here is how to solve it—and why thinking in two dimensions is the secret to solving 3D problems.
What is the spider and fly problem?
The problem was originally posed by mathematician Henry Dudeney in the English newspaper *Weekly Dispatch* on 14 June 1903, and later published in his 1907 book *The Canterbury Puzzles*.
The setup is precise:
The room is 30 feet long, 12 feet wide and 12 feet high.
The spider is on one of the square end walls, 1 foot below the ceiling and centred horizontally (6 feet from each side).
The fly is on the opposite end wall, 1 foot above the floor and also centred horizontally.
The fly is frozen in fear. The spider must crawl along the surfaces of the room to reach it.
What is the minimum distance the spider must travel?
What is the naive solution?
When we imagine the room, our brains default to following the straightest-looking lines parallel to the walls.
The obvious route is to go straight over the top. The spider crawls up 1 foot to the ceiling. It walks 30 feet straight across the length of the ceiling. Finally, it crawls 11 feet down the opposite wall to reach the fly (since the fly is 1 foot above the floor in a 12-foot high room).
Adding these up gives 1 + 30 + 11 = 42 feet. You get the same distance of 42 feet if the spider takes the floor route instead.
However, 42 feet is not the shortest path.
How to find the shortest path on the surface of a room?
To find the true shortest path on a 3D surface, you have to stop thinking in 3D. The trick is to "unfold" the cuboid room into a flat 2D shape, known as a net. Once the room is flat, the shortest distance between two points is simply a straight line.
You can experiment with interactive nets in the Fermi Simulation Lab to see how 3D shapes unfold. Depending on how you choose to unfold the six faces of the room, the straight line between the spider and the fly will cross different walls.
The optimal unfold for this specific room lays out five of the six faces in a staggered pattern:
The spider's wall (End Wall 1)
The ceiling
One of the side walls
The floor
The fly's wall (End Wall 2)
If you draw a straight line between the spider and the fly on this specific flat net, the path cuts diagonally across all five faces.
Why does unfolding the room reveal the answer?
When you flatten the room in this way, you can calculate the distance for the classic solution using Pythagoras' theorem (a² + b² = c²).
Let's look at the horizontal and vertical distances on our flattened map:
Horizontal distance: The spider is 1 foot from the ceiling edge. The room is 30 feet long. The fly is 1 foot from the floor edge. Total horizontal distance = 1 + 30 + 1 = 32 feet.
Vertical distance: The spider is 6 feet from the side wall. The side wall is 12 feet high. The fly is 6 feet from the other side wall. Total vertical distance = 6 + 12 + 6 = 24 feet.
Now, apply the theorem to the right-angled triangle with sides of 32 and 24: c = √(32² + 24²) c = √(1024 + 576) c = √(1600) c = 40 feet.
By taking a spiral route that touches five of the six walls, the spider saves 2 feet compared to the obvious ceiling route.
How do you solve similar shortest path problems?
Whether you are preparing for a competitive exam or solving physics problems step by step, the method is always the same:
Identify the faces: Work out which walls or surfaces the path might cross.
Draw the net: Flatten those surfaces into a 2D plane.
Plot the points: Mark your start and end positions accurately on the flat drawing.
Draw a straight line: Connect the dots.
Calculate the hypotenuse: Use the grid to find the horizontal and vertical components, and apply Pythagoras' theorem.
If you are stuck visualising how a 3D geometry problem translates to a 2D diagram, you can ask the AI tutor in the Fermi Problem Library to walk you through the unfolding step by step. Try testing different unfold patterns—sometimes the path that looks the most complicated in 3D turns out to be the simplest straight line on paper.



