Solution to exercise 3 from 1.7 module - chap1