solutions to prob 5 and 6. this is getting easier.