brute force python solution for problem 32