Committing complete version of exercise 11 from chapter 7.