exercises 2.59 & 2.60
tweak to this older file
tweaking implementation after seeing Bill-the-Lizard's
exercises 2.61 & 2.62