Solved problem 9, slightly verbose. -Chaz