MATLAB: Sudoku Solver – SciLab – Error 4

algorithmbacktrackingerrorscilabsolversudoku

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.

Best Answer

  • 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.