Most Efficient Brute Force

What is the most efficient way to brute force through a 2D array, trying different possibilities?

It is for the final, brute force stage, of a Sudoku solver.
There isn't really one. The whole point of "brute force" is that you just try everything. The only way to be more efficient would be to not try things that are unlikely to work (in which case you are no longer brute forcing). The best you can do is stop one approach as soon as it is apparent that it will not work.

To brute force a sudoku problem, you would:

1) fill the first gap with a number.
- is that number a legal move?

no: try the next number. If there are no more numbers, the unwind to the previous gap and try its next number.

yes: fill the next gap with a number. No more gaps? then you found the solution.
Perhaps I will just focus on trying to avoid brute force in almost all cases then. ;)
The advantage of brute force is that it pretty much always works... except in cases where the problems get too large to be solvable in reasonable time like that. Also, it's usually simple to implement.
Topic archived. No new replies allowed.