Adding the solution to problem 24.