solved fourth problem, brute force