Qm
BrainteasersJane StreetOptiver

The spider and the fly

A rectangular room is 30 feet long, 12 feet wide and 12 feet high. A spider sits on the middle line of one end wall, 1 foot below the ceiling. A fly sits on the middle line of the opposite end wall, 1 foot above the floor, and does not move.

The spider must crawl along the walls, ceiling or floor (no jumping, no webs).

What is the length of the shortest route? The straightforward route, up 1 foot to the ceiling, 30 feet along the ceiling, and 11 feet down the far wall, is 42 feet. Beat it.

Show a hint

Unfold the room into a flat net of rectangles and draw straight lines. There are several ways to unfold; the best route crosses five of the six faces.

Your answer

Solving needs a free account

Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. No full solutions here. Hints and approaches only.
  2. Complexity, edge cases and intuition are the point.
  3. Interview experiences are welcome. Respect your NDAs.

Loading discussion…

Learn the concepts

The theory behind this question.

Related questions

The ant crawling across a boxThe bookworm and the ten volumesWhich barrel holds the beer?Dropping needles to estimate piHalving a cake that already has a piece missing
All questions →