A fun algorithmic problem

Gunnar posted a very interesting problem.  I gave it two mental stabs before running into walls.  So I'm going to break out a good pad of paper and see if I can get it.