This function works as expected when the order is a list of 0 to 80, however if order is a randomly shuffled list then the function takes incredibly long (sometimes upwards of a minute) but usually gets the correct answer.
The reason may be that while the recursion tree grows exponentially with the recursion depth, when you process the numbers row by row (rather than in a random order), most of the invalid arrangements are cut out early. You'll never have to process the second row with the first row being inconsistent.
When order is a list of numbers from 80 to 0, the function does not solve anything and always returns false.
A couple suggestions:
1) Try replacing order(i)
with 80-i
to make sure the problem is not in the order()
function;
2) Every time you call check_conflicts(board, order(i))
, call also check_conflicts(inverse(board), 80-order(i))
and throw an exception if their results are not equal.