An Exercise in Algorithms by Leif Haley