Adding the solution to homework 6.