Hi everyone. I have been trying to understand what is wrong with my program. It is the dumb 8 queens problem where we have to place 8 queens on a chess board while making sure they dont kill each other off. My program using backtracking works perfectly but the dumb 8 version does not. Here is my code
The loop has no reason to be infinite. It's just that 810/2 cycles will take a while.
Also, I don't see an error in ok(). What kind of wrong results did it produce ?
To make this brute thing faster (but still ridiculously slow), notice that of all combinations of 8 numbers 0 to 7, only the ones that have no repetitions interest you. These combinations are permutations of 01234567. Look into http://www.cplusplus.com/reference/algorithm/next_permutation/