Solve problem 2 of hw4