solving problem 5 with brute force.