problem 8 & 9. brute force solutions.