brute forced solution, runs in 29s