The spider and the fly problem


The spider and the fly problem is a recreational geodesics problem with an unintuitive solution.

Problem

In the typical version of the puzzle, an otherwise empty cuboid room 30 feet long, 12 feet wide and 12 feet high contains a spider and a fly. The spider is 1 foot below the ceiling and horizontally centred on one 12′×12′ wall. The fly is 1 foot above the floor and horizontally centred on the opposite wall. The problem is to find the minimum distance the spider must crawl along the walls, ceiling and/or floor to reach the fly, which remains stationary.

Solutions

A naive solution is for the spider to remain horizontally centred, and crawl up to the ceiling, across it and down to the fly, giving a distance of 42 feet. The shortest distance strictly abiding by the rules, 40 feet, is obtained by constructing an appropriate net of the room and connecting the spider and fly with a straight line.
A lateral thinking solution involves the spider attaching dragline silk to the wall to lower itself to the floor, and crawling 30 feet across it and 1 foot up the opposite wall, giving a crawl distance of 31 feet. Similarly, it can climb to the ceiling, cross it, then attach the silk to lower itself 11 feet, also a 31-foot crawl.
An even more drastic solution has the spider crawling up 1 foot, and forward an infinitesimal distance δx along the centre line of the ceiling. It then attaches silk to the ceiling, lowers itself δx and, as in pumping a swing, swings itself up to the ceiling at 2δx, repeating the process until it reaches the far wall. Lastly, it attaches silk to the far wall to lower itself to the fly. The total crawling distance is 1 foot + δx, which tends to 1 foot as δx tends to zero.

Generalisation

For a room of length l, width w and height h, the spider a distance b below the ceiling, and the fly a distance a above the floor, the optimal distance o is while the naive distance n is.
This table gives integer solutions for and sorted by ascending o then with the original values in bold.

History

The problem was originally posed by Henry Dudeney in the English newspaper Weekly Dispatch on 14 June 1903, presented in The Canterbury Puzzles and described by Martin Gardner.