Solution to exercise 9 from 1.7 module - chap1