Adding solution to homework 4