solution to prob 17 finished