I have a problem with my sudoku solution method. The program works as follows; the board is empty at startup, users will add a couple of numbers to the board, and then by clicking the Solve button, the program tries to solve it. Everything works fine if I put the same number on the same line. Therefore, if the user adds 1,1,0,0 ... 0. In the puzzle he cannot solve it, because his two 1 are next to each other and will continue to aggressively try to find the sulothion, although its an insoluble puzzle. However, if they were all 0 (empty), this would immediately solve it, as if Id put 1 and 2 in the upper left corner. If I just put some random numbers in it, he would detect it as unsolvable (or solve it if it's a valid puzzle)
I ponder the lines, saying that theNumber == (row, col) equals thenNumber == (row+1, col) , it should return false because it is a duplicate number.
This is the code I tried to add to the solution method, obviously without success.
if ((puzzle.getNum(row, col) == a) == (puzzle.getNum(row + 1, col) == a)) { return false; }
Help with thanks
Rob
source share