Completed hw4 solution.