Best first brute-force algorithm