Solution to exercise 5 from 1.7 module - chap1