Sudoku Solver - SciLab - Error 4
3 views (last 30 days)
Show older comments
Jonas Degroote
on 16 May 2015
Edited: Walter Roberson
on 16 May 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 Comments
Accepted Answer
Geoff Hayes
on 16 May 2015
Edited: Geoff Hayes
on 16 May 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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!