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   

Medusa + reverse logic solves all 520 of impossible.db

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

Joined: 05 Oct 2005
Posts: 187
:
Location: St. Olaf College

Items
PostPosted: Fri Nov 04, 2005 12:14 am    Post subject: Medusa + reverse logic solves all 520 of impossible.db Reply with quote

OK, I need a puzzle that Sudoku Assistant doesn't solve. Who's got it?

With

http://www.stolaf.edu/people/hansonr/sudoku

the entire set of 520 puzzles at

http://home.comcast.net/~mshelor/files/impossible.db

is solved in 50 minutes on my lab Gateway PC. (Averaging about 6 seconds each; Opera turns out to be an order of magnitude faster than MSIE here, by the way). This could be faster, but I figure that it's more fun to watch the solution go than try to get it very fast. JavaScript will never be very fast, anyway.

The two techniques, in addition to standard cross-hatching, block row/column exclusions, subsets, and grids that make this happen include:

Medusa:

Really just full 3D forcing chains -- no "bifurcation"

Hypothesis and Proof:

Postulating "X can be eliminated" followed by direct logical proof that this statement is true.

I think there's a puzzle out there that can stall this, but I just can't find it.
I wish someone would code this in a language that could process 200M of these so we could see what sticks.
_________________
Bob Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Fri Nov 04, 2005 12:55 am    Post subject: Reply with quote

Have you tried the folowing famous puzzles?

Menneske 2155141

Code:
. . .|6 . .|4 . .
7 . .|. . 3|6 . .
. . .|. 9 1|. 8 .
-----+-----+-----
. . .|. . .|. . .
. 5 .|1 8 .|. . 3
. . .|3 . 6|. 4 5
-----+-----+-----
. 4 .|2 . .|. 6 .
9 . 3|. . .|. . .
. 2 .|. . .|1 . .


Rubylips 48-Unwind

Code:
. . .|. . 3|. 6 .
. . .|. . .|. 1 .
. 9 7|5 . .|. 8 .
-----+-----+-----
. . .|. 9 .|2 . .
. . 8|. 7 .|4 . .
. . 3|. 6 .|. . .
-----+-----+-----
. 1 .|. . 2|8 9 .
. 4 .|. . .|. . .
. 5 .|1 . .|. . .


Tilps toughest

Code:
. . .|1 . .|7 . .
. 2 .|6 9 .|. . .
9 . .|. . 3|. 8 2
-----+-----+-----
. . .|. . .|4 6 .
6 4 .|. . .|. 5 7
. 5 8|. . .|. . .
-----+-----+-----
2 1 .|8 . .|. . 9
. . .|. 1 6|. 7 .
. . 4|. . 2|. . .


Uniqueness sample by Lummox JR, on the players forum. Requires test 3.

Code:
. . 9|. . .|. . .
. . 5|. 6 .|. 4 7
. . 7|. 4 9|. 1 .
-----+-----+-----
. . .|6 . .|2 . 5
. . 1|. 3 .|. . 4
6 . .|. . .|. . .
-----+-----+-----
. . .|. . 2|. 7 3
9 . .|. 7 .|6 . .
. . .|1 . .|. . 8


One found at http://www.pmilne.net/SuDoku/

Code:
. . .|. . .|. . .
. 1 7|3 . .|8 9 .
. 4 9|8 . .|7 2 .
-----+-----+-----
. . .|. . .|2 5 6
. . .|4 . 5|. . .
5 7 3|. . .|. . .
-----+-----+-----
. 6 2|. . 3|5 8 .
. 5 1|. . 9|4 7 .
. . .|. . .|. . .


I can solve them, but they have a reputation for toughness.

Ruud.
Back to top
View user's profile Send private message Visit poster's website
Lummox JR

Joined: 07 Sep 2005
Posts: 202
:

Items
PostPosted: Fri Nov 04, 2005 1:14 am    Post subject: Reply with quote

My solver rates these fairly low. The infamous 48-unwind was already known to fall to one round of advanced coloring, but of the group Tilp's toughest is the only one that presents a big enough challenge to use bifurcating chains. Given that Bob's solver is using some form of that technique now, I doubt there's a puzzle it won't solve.

The puzzle example you got from my post is apparently not a uniqueness 3; it uses tests 2 and 4. Since it uses nothing more complex, my solver rates it with fairly low difficulty.

The sticking point with the last puzzle appears to be a quad in column 1. Kinda hard to find, but not impossible, and after that it hardly poses any challenge.
Back to top
View user's profile Send private message
Bob Hanson

Joined: 05 Oct 2005
Posts: 187
:
Location: St. Olaf College

Items
PostPosted: Sun Nov 06, 2005 12:29 pm    Post subject: Reply with quote

Menneske 2155141

http://www.stolaf.edu/people/hansonr/sudoku/index.htm?t-6t-4t-7t,,-3,-6tt,-9,-1,,-8tttt-5,,-1,-8t,-3t,-3,,-6,,-4,-5,,-4,,-2t,-6,,-9,,-3tt,,-2t,,-1

32 steps. The only interesting thing there is in Step 9:
13 strong chains
r3c7 ISN'T 3: strong incompatibility on 3 at cell r3c7 (involving nodes r3c7#3 chain 1(0) and r3c2#3 chain 1(0))

Rubylips 48-Unwind

http://www.stolaf.edu/people/hansonr/sudoku/index.htm?t,,-3,,-6ttt-1t-9,-7,-5t,-8tt-9,,-2t,,-8,,-7,,-4t,,-3,,-6tt-1t,-2,-8,-9t-4ttt-5,,-1

Again, nothing much there except

Step 10
18 strong chains
r4c8 ISN'T 7: strong incompatibility on 7 at cell r4c8 (involving nodes r4c8#7 chain 5(1) and r4c8#3 chain 5(1))

Tilps toughest

http://www.stolaf.edu/people/hansonr/sudoku/index.htm?t-1t-7t,-2,,-6,-9t,,-9t,,-3,,-8,-2tt,-4,-6,,-6,-4tt-5,-7,,-5,-8tt,-2,-1,,-8t,,-9t,,-1,-6,,-7t,-4t-2

This is more interesting. 49 steps required. Try it yourself and see. Too much interesting stuff to highlight here.

Uniqueness sample by Lummox JR, on the players forum. Requires test 3.

http://www.stolaf.edu/people/hansonr/sudoku/index.htm?,,-9ttt-5,,-6t-4,-7t-7,,-4,-9,,-1t,,-6t-2,,-5t-1,,-3t,-4,-6tttt,,-2,,-7,-3,-9t,-7,,-6tt-1t,,-8

22 steps. Only one interesting feature:

Step 14
28 cells left to solve
6 strong chains
r1c9 ISN'T 2: strong incompatibility on 2 at cell r1c9 (involving nodes r1c9#2 chain 1(0) and r1c4#2 chain 1(0))


One found at http://www.pmilne.net/SuDoku/

http://www.stolaf.edu/people/hansonr/sudoku/index.htm?ttt,-1,-7,-3t-8,-9t-4,-9,-8t-7,-2tt,,-2,-5,-6t,-4,,-5t,-5,-7,-3tt,,-6,-2t-3,-5,-8t-5,-1t-9,-4,-7

19 steps; nothing special of note.

Is it really possible that this is as hard as they get?
_________________
Bob Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sun Nov 06, 2005 1:34 pm    Post subject: Reply with quote

try 16*16 then !
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bob Hanson

Joined: 05 Oct 2005
Posts: 187
:
Location: St. Olaf College

Items
PostPosted: Sun Nov 06, 2005 2:19 pm    Post subject: Reply with quote

nah, just the same only bigger, I'm sure.
_________________
Bob Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Sun Nov 06, 2005 2:42 pm    Post subject: Reply with quote

With the current speed of Sudoku Assistant, trying 16x16 might not be a good idea.

O(9^4) = 6561
O(16^4) = 65536

(I think)
Back to top
View user's profile Send private message Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sun Nov 06, 2005 3:06 pm    Post subject: Reply with quote

that would be only a factor of 10 !
It's NP-complete, so expect exponential behaviour.
Or you can't solve even averagel puzzles.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
xyzzy

Joined: 24 Aug 2005
Posts: 80
:

Items
PostPosted: Sun Nov 06, 2005 3:16 pm    Post subject: Reply with quote

Bob Hanson wrote:
nah, just the same only bigger, I'm sure.

What happens if every possible subset has more than two possibilities? Then there are no strongly associated nodes, right? Won't your algorithm pretty much die then?

It sounds like your method is a breadth first search with a maximum depth of 1, which means it is non-recursive. On each trial you are only allowed to use singles to find more eliminations. You implemented it with implication chains, but since those chains are found just with singles, it ends up the being the same thing.
Back to top
View user's profile Send private message Visit poster's website
Bob Hanson

Joined: 05 Oct 2005
Posts: 187
:
Location: St. Olaf College

Items
PostPosted: Tue Nov 08, 2005 10:02 pm    Post subject: Reply with quote

Quote:
What happens if every possible subset has more than two possibilities? Then there are no strongly associated nodes, right? Won't your algorithm pretty much die then?

This is an interesting question. I would have thought so. It appears that the preliminary subset elimination is so effective that it takes care of all such possibilities. I don't think I can prove that. Find me a puzzle that requires it, and I'll look into it. I've said all along that there might be such a puzzle. I just haven't been able to find one. Not being a mathematician, I don't know how to prove the algorithm really does solve all Sudoku. That would have to be SOME puzzle, though!
Quote:

It sounds like your method is a breadth first search with a maximum depth of 1, which means it is non-recursive.

The method is general, but the implementation is breadth only. It doesn't require any depth to solve all puzzles (so it appears...), so there was no need to implement depth. It's highly recursive, but not in the way you are referring to. Do you have an example of a puzzle that requires depth?

As for this O(9^4) business, I'm not so sure of that. This makes it sound as though the algorithm were impossible or something. But it's working like a charm. I think, again, you are forgetting that all this happens after chains are constructed, and the chain construction effort itself generally leads to eliminations. Perhaps you are thinking in terms of a hypothesis/proof-only solver, which this is not. I agree completely that if one implemented ONLY this logic, it would be very, very slow. And it would need more than just breadth level 1.

16x16: I'm fairly certain the extension to 16x16 would be quite simple. There are no new principles there, just more to do. No, I'm not going to do it myself. I'm happy with a solver that solves all unique 9x9s (so far investigated).

So I'll let others discuss it or try it on 16x16.
_________________
Bob Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
Back to top
View user's profile Send private message Send e-mail Visit poster's website
xyzzy

Joined: 24 Aug 2005
Posts: 80
:

Items
PostPosted: Fri Nov 11, 2005 2:26 am    Post subject: Reply with quote

Quote:
This is an interesting question. I would have thought so. It appears that the preliminary subset elimination is so effective that it takes care of all such possibilities. I don't think I can prove that. Find me a puzzle that requires it, and I'll look into it. I've said all along that there might be such a puzzle. I just haven't been able to find one. Not being a mathematician, I don't know how to prove the algorithm really does solve all Sudoku. That would have to be SOME puzzle, though!

I looked for some 16x16s that have this property, and couldn't find any. Seems that if you make eliminations using locked subsets, there always ends up being at least one strong pair.

Then I implimeted a breadth first search that limits its depth to 1 and uses locked subsets before each search. You could call it non-recursive trial and error. As far as I can tell, your program does the same thing, just in a more roundabout way. Sure enough, this can solve any 9x9 I tried. However for 16x16 almost none can be solved! Try this one:
Code:

-------------+-------------+-------------+-------------
 14 .. .. .. | .. .. .. 15 | 11 .. ..  8 |  1  2 .. ..
 15 .. .. 11 | .. .. .. .. | .. 12 10 14 |  8 .. .. ..
  3 ..  5 .. | .. .. .. .. | .. ..  6 .. |  9 .. .. ..
 ..  1 13 .. |  8 .. .. .. | 15 .. .. .. | ..  7  4 10
-------------+-------------+-------------+-------------
 .. .. .. .. |  7 ..  3  8 |  4 ..  2 10 | ..  6 12 ..
  5 12 15  3 | .. .. ..  1 |  9 11 13  7 | .. .. .. 16
 .. .. .. .. | ..  2 .. .. |  5 .. 14 16 | .. .. .. ..
 .. .. ..  4 | .. .. ..  9 |  8 .. 12 .. | .. .. 11 ..
-------------+-------------+-------------+-------------
 12 ..  2  7 | 13 .. .. .. | 10 .. .. .. | .. .. .. ..
  1 .. .. .. | 15 .. .. 11 | 12 .. ..  2 | .. 10 .. ..
 11  9 16 10 |  2 12 ..  7 |  6 ..  3 .. | 15 .. .. 13
 ..  4 .. .. | .. 10 .. .. | 14 .. .. .. |  5 12 ..  2
-------------+-------------+-------------+-------------
 .. .. 14 .. |  9  7  1 .. | ..  5 .. .. | .. .. .. ..
 13 .. .. .. |  3  6  2 14 |  7 16 15 12 |  4  5 .. ..
 .. .. 12 .. |  4  8 10 .. | .. 14  1  6 | .. 13 .. 11
 ..  7 .. .. | 11 15 12 .. | .. 10 ..  9 | .. .. .. ..
-------------+-------------+-------------+-------------

None of the possible nodes to try will lead to a contradiction using just singles.
Back to top
View user's profile Send private message Visit poster's website
Bob Hanson

Joined: 05 Oct 2005
Posts: 187
:
Location: St. Olaf College

Items
PostPosted: Fri Nov 11, 2005 2:41 pm    Post subject: Reply with quote

prior to this you've checked for all X-wing-like objects?
_________________
Bob Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
Back to top
View user's profile Send private message Send e-mail Visit poster's website
xyzzy

Joined: 24 Aug 2005
Posts: 80
:

Items
PostPosted: Fri Nov 11, 2005 10:16 pm    Post subject: Reply with quote

Yes, there should be no locked tuples in any dimension than result in eliminations.
Back to top
View user's profile Send private message Visit poster's website
Bob Hanson

Joined: 05 Oct 2005
Posts: 187
:
Location: St. Olaf College

Items
PostPosted: Fri Nov 11, 2005 10:43 pm    Post subject: Reply with quote

yes, but I mean ALL objects of that nature, not just tuples? Just the general class of objects that "transcend" strong edges. Once those are gone, I would think the rest is cleanup.
_________________
Bob Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bob Hanson

Joined: 05 Oct 2005
Posts: 187
:
Location: St. Olaf College

Items
PostPosted: Mon Nov 14, 2005 7:40 pm    Post subject: Reply with quote

Thanks for this example. It got me thinking more about what the
Sudoku Assistant is doing. I've added more discussion there.

Yes, I agree that (mostly) what this is is a breadth ONLY strategy. The one added technique, {?FFF...} --> {TFFF...}, is actually just the first step of a second-pass depth-like strategy. It amounts to looking for hidden singles.
_________________
Bob Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
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 -> 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