Solution to exercise 2 from 1.7 module - chap1