The spider-and-fly problem is a puzzle that was originally posed in the Weekly Dispatch, an English newspaper, on June 14, 1903, by Henry Dudeney, and that appears as one of the problems in The Canterbury Puzzles (1907).1 A simple but elegant exercise in geodesics, it is Dudeney's best-known brain-teaser. In a cuboidal (shoebox-shaped) room measuring 30 ft × 12 ft × 12 ft, a spider is in the middle of one 12 ft × 12 ft wall, one foot away from the ceiling. A fly is in the middle of the opposite wall one foot away from the floor. If the fly remains stationary, what is the shortest total distance (the geodesic) the spider must crawl along the walls, ceiling, and floor in order to get to the fly? The answer, 40 ft, can be obtained by flattening out the walls. Note that this distance is shorter than the 42 ft the spider would have to travel if it first crawled along the wall to the floor, then across the floor, then up one foot to get to the fly.
A twist to the problem can be obtained by a spider that suspends himself from strand of cobweb and thus takes a shortcut by not being forced to remain glued to a surface of the room. If the spider attaches a strand of cobweb to the wall at his starting position and lowers himself down to the floor (thus not crawling a single inch), he can then cross the length of the room by foot (30 ft) and ascend a single foot, thus reaching his prey after a total crawl of 31 ft (although the total distance traveled is of course 42 ft). If the spider is not proficient with fastening strands to vertical walls, he must first ascend 1 ft to the ceiling, from where it can lower himself to the floor, traverse the length of the room, and climb one foot to get to the fly, for a total distance crawled of 32 ft.
Dudeney and Stanley Loyd offered several versions of the problem in a rectangular room. In 1926 Dudeney gave a version on a cylindrical glass with the source and the target on opposite sides.
1. Dudeney, H. E. The Canterbury Puzzles. London: Nelson, 1907. Reprinted Mineola, NY: Dover, 1958.