The Frog in the Well
The puzzle
A frog is at the bottom of a well thirty feet deep. Each day it climbs three feet; each night it slips back two.
On which day does it get out?
Stuck?
One at a time, smallest first. Open only as many as you need — the whole point of the puzzle is the part you work out yourself.
Hint 1
Net progress is one foot a day, so thirty days is the obvious answer. Check what happens on the last climb.
Hint 2
Once the frog is out, it does not slip back.
Show the answer Hide the answer
Day 28.
How to get there
Each full day-and-night gains one foot, so after 27 days the frog is 27 feet up.
On day 28 it climbs three more, reaching 30 feet - the top - and leaves. There is no night-time slip because it is already out.
Answering 30 treats the final climb as if it were followed by a slip, which is the whole trap.
The technique worth keeping
Handle the final step separately from the repeating ones. Any process with a per-cycle gain and a terminating condition needs the last cycle checked on its own, which is the same care a loop boundary needs.