Code from the book Understanding Computation ported from Ruby into Python