Sudoku Solver - SciLab - Error 4

12 visualizaciones (últimos 30 días)
Jonas Degroote
Jonas Degroote el 16 de Mayo de 2015
Editada: Walter Roberson el 16 de Mayo de 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.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 16 de Mayo de 2015
Editada: Geoff Hayes el 16 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Sudoku en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by