Solve problem 81 using Python.
Simplify implementation of Ruby's problem 81.