example problems from Bentley's programming pearls written in Python