Implementing algorithms from "Algorithms Unlocked" in Python