Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

Checking for uniqe solution
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku
View previous topic :: View next topic  
Author Message
lkSudoku

Joined: 16 May 2009
Posts: 60
:

Items
PostPosted: Fri Nov 27, 2009 5:20 pm    Post subject: Reply with quote

Of course the algorithm I suggested is not optimized nor quick, I only tried to answer the question in the beginning of the thread and suggest a proof of correctness

What I do in my program is as follows:
In order to check for multiple solutions, I first try to solve while allowing backtracking and using the fastest solving methods; once a solution is found, I continue to solve with backtracking as if the solution was an error until either there is another solution (and the previous solution is not unique) or there is no other solution thus the first solution is unique

When performing backtracking I always try one of the cells with minimal number of candidates (with more than one candidate) to decrease the number of guesses
Back to top
View user's profile Send private message Send e-mail
sudoking

Joined: 20 Oct 2009
Posts: 40
:

Items
PostPosted: Sat Nov 28, 2009 12:42 pm    Post subject: Reply with quote

Lunatic wrote:
You can check the "checkuniqueness" routine within the c code from my random sudoku generator example at
http://users.telenet.be/mpq/sudoku/random_sudoku_generator.c


I used that one for a while in my generator. However, I replaced it with a modified version of the bb_sudoku algorithm, which was much faster.
Back to top
View user's profile Send private message
Lunatic

Joined: 11 Mar 2007
Posts: 166
:
Location: Ghent - Belgium

Items
PostPosted: Sat Nov 28, 2009 4:08 pm    Post subject: Reply with quote

sudoking wrote:
Lunatic wrote:
You can check the "checkuniqueness" routine within the c code from my random sudoku generator example at
http://users.telenet.be/mpq/sudoku/random_sudoku_generator.c


I used that one for a while in my generator. However, I replaced it with a modified version of the bb_sudoku algorithm, which was much faster.


I know that Brian has a much better algorithm, but I wanted to provide a C code example with a low threshold, especially for newbies.

Furthermore, I'm not used to write C code, I prefer Visual Basic, but VB has not the same capabilities as C/C++. The C code is in fact a translation from my VB code. Maybe I will, someday, when I'm retired Smile , switch to C/C++, I do have the Visual Studio suite.
_________________
Marc
~~~<><~~~<><~~~<><~~~<><~~~
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron