solved problem 5 with brute foce, plan to look for more efficient solution eventually