problem 14 (not finished, brute force that is too slow)