problem 5 brute force (doesn't scale past 10)
answer for problem 5