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.

 채택된 답변

Geoff Hayes
Geoff Hayes 2015년 5월 16일
편집: Geoff Hayes 2015년 5월 16일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Sudoku에 대해 자세히 알아보기

질문:

2015년 5월 16일

편집:

2015년 5월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by