Implemented brute force solver (not tested)