Solution code to homework5