First version of exercise 3 in chapter 2.