# 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.[1]

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

lwhbanono
22551127261
22991131301
28881136342
28971135341
2611101136351
33661139372
33751138371
34871141392
34961140391
3012121142402
3013111141401
38541142411
3414131147452
3415121146451
3815151153503
3816141152502
3615152251501
3715151251501
3715152151501
3817131151501
4017162256551
4020201160582
3821211159581
4021191159581

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 ${\displaystyle {\sqrt {(w+h)^{2}+(b+l+a)^{2}}}}$ while the naive distance n is ${\displaystyle l+h-|b-a|}$.

This table gives integer solutions for l, w 40, h w and o < n, sorted by ascending o then no, 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 (1907) and described by Martin Gardner.[2]

## References

1. Weisstein, Eric W. "Spider and Fly Problem". Mathworld.wolfram.com. Retrieved 1 March 2019.
2. Darling, David. "spider-and-fly problem". Daviddarling.info. Retrieved 1 March 2019.