At post-pizza last night Ian set me an algorithms problem, because he thought it would be right up my street. The solution I came up with turned out to be overkill for his actual needs, but it was a rather cute use of annotated trees which I hadn't thought about before, so I want to write it down somewhere.
( algorithms geekery )