Solution to exercise 6 from 1.7 module - chap1