Solved problem 5, made solution to problem 4 succinct. -Chaz