Homework #2 solution