I was asked to solve this puzzle once during a project management interview. The solution here says &quot;work backwards,&quot; but I found that &quot;work recursively&quot; was a more helpful (and instructive) way to think about it.