hi to all
I am a mechanic engineer and I had written a program to solving Sudoku,
and if your sudoku have more than one answer,it will be show all nswers;
But if you enter an empty sudoku,computer most claculate your answers in"for loop" for 9^81 times.
Is there any way to solve this problem?
thank you.
Showing all answers is pointless because no one is going to look at all of them. Easiest is just to set a limit on how many solutions that you calculate. Another way is to show one or a few solutions at the same time and let the user press a button to see other solutions. For that to work you can build the solver in a way that makes it possible for it to run until it finds N answers, and be able to later continue the calculation from where it was. Each time the user press the button you just ask the solver for more solutions.
Thank you Peter87
But I had wrote to my program if you find one answer:Break;
But it also had the same problem...
I ensure that my solution has no problem!!!
What is your input method? Depending upon the method you might be trying to solve something that isn't there (you never solve anything, no break).
If you post code on this forum, please to it in code tags. You can make code tags by clicking the <> button to the right of the text box. Any code should go between the [] (code here) [/].