Solution for problem22

Written against trunk.  I feel like I'm doing this horribly wrong.