My homework solution for Design of Computer Programs by Peter Norvig