Finding a Hermit


I got this problem from Rustan Leino, who got it from Claude Marché.

I solved it and wrote up my solution.


There are five holes arranged in a line. A hermit hides in one of them. Each night, the hermit moves to a different hole, either the neighboring hole on the left or the neighboring hole on the right. Once a day, you get to inspect one hole of your choice. How do you make sure you eventually find the hermit?

Solution     Reveal