Sudoku Solver - SciLab - Error 4
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonas Degroote
am 16 Mai 2015
Bearbeitet: Walter Roberson
am 16 Mai 2015
So I am trying to write a program that solves sudoku's. I'm using scilab at the moment.
I keep getting errors in my recursive algorithm and I don't see what's wrong. Any help is welcome.
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 16 Mai 2015
Bearbeitet: Geoff Hayes
am 16 Mai 2015
Jonas - line 24 of your recursive solve function looks like
solve(board) // and we repeat until check(board) gives true
Note how you don't handle the return value from this function. I suspect that a first step is to do
S = solve(board)
Also, as your function manipulates the input board (I'm not familiar with Scilab so don't know if this input is passed in by value or by reference,) I'm guessing that you should also update S with the manipulated board as
S(x,y) = 0
in place of
board(x,y) = 0
Try making the above changes and see what happens. Using a debugger is also a good idea in solving problems like these.
EDIT - to be clear, your code needs to assign something to S when you enter the else body of the function as S is the return value from the function. So the above may not be sufficient if possibilities has no value that is greater than zero.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!