problem 47 solved with heavy brute force and ~2m running time