Solution to exercise 8 from 1.7 module - chap1