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   

need help finding my own solving algorithm on this forum

 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku
View previous topic :: View next topic  
Author Message
shoop

Joined: 17 Aug 2006
Posts: 35
:

Items
PostPosted: Thu Aug 17, 2006 12:25 am    Post subject: need help finding my own solving algorithm on this forum Reply with quote

I've been looking through the stickies and maybe I'm not looking carefully enough but I was wondering what my sudoku solving algorithm is called - I'm sure it must be well known since it is so simple. Yet it is completely general: it covers all reasoning that can be done without considering multiple houses at once.

It seems extremely related to the concept of "hidden subsets", but it may be slightly more general? It encompasses most simple solving techniques I think: all kinds of cross-hatching and locked candidates. It cannot handle patterns that require chains to be detected, such as x-wing. I'm not sure about strategies such as colouring or patterns, which I don't understand yet. I'm sure it can't handle those either.

1. For each cell, store which digits are still possible (the 'candidates' or 'pencil marks'). Cells for which the digit is given have one candidate, all other cells initially have nine.

2. Repeatedly make deductions within each house until none can be made in any house:

2a. Make a binary table that offsets the nine candidates against the nine cells in the house. (My implementation uses boolean logic and an array of nine ints to do this.) Each entry in the table is set to 'false' if that digit is not allowed in that cell, and 'true' otherwise.

2b. Now look if there are equal rows. If you can find N equal rows in which N elements are true, then this means that those N digits must go into those N places. Therefore those digits cannot occur in any other places. Thus, the corresponding bits can be cleared in all other rows.

2c. The same rule works in the other direction: if you can find N equal columns in which N elements are true, then this means that those N digits have nowhere else to go than into those places, so no other digits can go into those places. Ergo, the corresponding bits are cleared in all other columns.

Steps 2b and 2c are each others mirror image, but for bitvectors rows are easier to handle than columns. I nevertheless implemented only 2b; 2c is obtained by transposing the matrix, applying 2b and transposing again.

So to repeat my question, what is this trick called, if anything?
Thanks.
Back to top
View user's profile Send private message
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Thu Aug 17, 2006 12:38 pm    Post subject: Reply with quote

You have implemented a limited search for naked and hidden subsets. If you perform an OR operation in the process, you'll find all subsets.

Here is a link to the topic that describes the method: http://www.setbb.com/sudoku/viewtopic.php?t=231&mforum=sudoku

cheers,
Ruud
_________________
Meet me at sudocue.net
Back to top
View user's profile Send private message Visit poster's website
shoop

Joined: 17 Aug 2006
Posts: 35
:

Items
PostPosted: Thu Aug 17, 2006 8:06 pm    Post subject: Reply with quote

Ruud wrote:
You have implemented a limited search for naked and hidden subsets. If you perform an OR operation in the process, you'll find all subsets.


Thanks a lot.
You're right about the limitation in my algorithm.
Very silly I didn't see that.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku All times are GMT
Page 1 of 1

 
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