The bug climbing out of a well

product-puzzle case · difficulty 2/5 · 15 minutes · other

Prompt

A bug is at the bottom of a 30-foot well. Each day it climbs 3 feet, and each night it slips back 2 feet. On which day does it get out of the well?

Context

A classic interview puzzle. Core idea: On day 27, it starts at 27ft. It climbs 3ft and reaches 30ft, escaping before night. Talk through your reasoning; the interviewer cares as much about structure as about the answer.

Clarifying questions

Does it slip on the last day?
Yes. Once the bug reaches the top (30 feet), it is out and does not slip back. It slips only at night, after a full day of climbing.

Recommendation

**Answer:** 28 days: it escapes during the climb on day 28. **Why:** Only the last day lacks a slip, so the bug needs to get within one day's climb of the top at a net rate of 1 foot a day, and then climbs out on the following day.

Risks

Next steps