Added the solution to exercise 5.