Added a solution to exercise 2.4.