, MasterPie wrote

Also, write a bunch of unit tests and write some of the methods recursively.

Rewrite it in Haskell.