Completed recursive brute force solver.