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   

Sudoku Solver.co.uk Challenge puzzles

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

Joined: 03 Jun 2005
Posts: 7
:

Items
PostPosted: Fri Jun 03, 2005 7:38 pm    Post subject: Sudoku Solver.co.uk Challenge puzzles Reply with quote

I've been following the discussions re: fishy cycles etc. very closely.

This technique is enough to solve the 1st challenge puzzle on http://www.sudokusolver.co.uk, which is great news, but apparently not the second.

Well I'd like to point out that according to Pappocom's solver the 2nd challenge puzzle on sudoku solver is actually not a valid puzzle - i.e. it is not solvable by logic!! (presumably trial and error is required).

Pappocom includes things like nishio, X-wing and swordfish in his rules of "logic". In the puzzles he sets himself he only allows X-wing, but when using his program to solve other puzzles Nishio and swordfish are allowed (and possibly extensions of swordfish ala fishy cycles).

So as far as we know (at least according to Pappocom's definition) we seem to have covered all the rules of sudoku logic.

It would be interesting to find out if Pappocom has just implemented swordfish or a generalized fishy-cycles algorithm. Does anyone have any higher-order fishy-cycle puzzles to hand??

Vin.
Back to top
View user's profile Send private message
Doug

Joined: 28 May 2005
Posts: 42
:

Items
PostPosted: Fri Jun 03, 2005 9:53 pm    Post subject: Re: Challenge Puzzles Reply with quote

I have a couple of comments:

The algorithm that gets the 1st challenge problem isn't Fishy Cycles, but rather the algorithm Simple Forcing Chains. Now, Simple Forcing Chains is subsumed under Limited Implication Trees, which hasn't been implemented yet. It may be that it gets the 2nd challenge problem. (I doubt it, but am loathe to run through it by hand on that problem.)

Another thought. The "logic rule lists" that abound are, of course, supposed to be "human implementable". Already some of the rules out there are getting to the strenuous limits of what a human can do by hand, and certainly in their head. Fishy Cycles is certainly on the edge, and I think some would say over it. Yet, there is no guarantee that someone won't come up with a fairly simple rule, yet unknown, that enables the solution of the 2nd challenge. Just having the current rule lists fail, doesn't mean that the puzzle can't be "done by logic". Indeed, I have another algorithm that I'm thinking about which might also make a difference on that 2nd challenge.

I don't have Pappocom's solver. But it includes Nishio, eh? Then Limited Implication Trees should be fair game too. It can be viewed as an extension of Nishio.

Sorry, I don't have an example of a longer Fishy Cycle Puzzle. One could contrive one though, without too much difficulty. If I have some time later, I'll post one here.
_________________
Doug Bowman
www.flickr.com/photos/bistrosavage
Back to top
View user's profile Send private message Send e-mail
vindaloo

Joined: 03 Jun 2005
Posts: 7
:

Items
PostPosted: Fri Jun 03, 2005 10:13 pm    Post subject: Re: Challenge Puzzles Reply with quote

Doug wrote:
I have a couple of comments:

The algorithm that gets the 1st challenge problem isn't Fishy Cycles, but rather the algorithm Simple Forcing Chains. Now, Simple Forcing Chains is subsumed under Limited Implication Trees, which hasn't been implemented yet. It may be that it gets the 2nd challenge problem. (I doubt it, but am loathe to run through it by hand on that problem.)


My bad! Thanks for pointing that out.

Quote:

Another thought. The "logic rule lists" that abound are, of course, supposed to be "human implementable". Already some of the rules out there are getting to the strenuous limits of what a human can do by hand, and certainly in their head. Fishy Cycles is certainly on the edge, and I think some would say over it. Yet, there is no guarantee that someone won't come up with a fairly simple rule, yet unknown, that enables the solution of the 2nd challenge. Just having the current rule lists fail, doesn't mean that the puzzle can't be "done by logic".


Thats why I make clear to use "solvable by logic" only in the Pappocom sense. You have to have a clear benchmark because there isn't a natural demarkation between "solvable by logic" and not "solvable by logic". Arguably trial-and-error is a form of logic.

Another point is how do sudokusolver.co.uk know that puzzle 2 is solvable by logic? Could they be mistaken?

Quote:
I don't have Pappocom's solver. But it includes Nishio, eh? Then Limited Implication Trees should be fair game too. It can be viewed as an extension of Nishio.

Sorry, I don't have an example of a longer Fishy Cycle Puzzle. One could contrive one though, without too much difficulty. If I have some time later, I'll post one here.


That would be very useful. At least we would know exactly what Pappocom considers to be fair logic!

Vin.
Back to top
View user's profile Send private message
PeteWake

Joined: 31 May 2005
Posts: 6
:
Location: UK

Items
PostPosted: Fri Jun 10, 2005 10:12 pm    Post subject: What is trial by logic? Reply with quote

Hi - I run the sudokusolver.co.uk site. Challenge puzzle 2 on the site is a great one because it noone has yet given the solve method that cracks it by logic. Yet we know it has a unique solution (try it on the main page with the 'check and guess' box checked and the 'return first' solution unchecked).

Sudoku puzzles fall into a class of problems mathemeticians call 'NP-hard' - which means that noone has yet found a way of solving every option by logic alone. However, the other way of looking at this (I think) is that there is an unbounded set of logic rules. However I am not a logic professor so I can't say with 100% confidence that this is the case.

To me, the point at which logic is left behind and guesswork begins is very clear - it is the point at which my program has to save a snapshot of the grid, reduce one gridpoint to one of the remaining possibilities and continue knowing it might have to come back.

I am now just keen for some earnest programmers to submit javascript code to solve method E.. which I don't think is guessing.

Happy sudokuing,
Pete Wake
Back to top
View user's profile Send private message Visit poster's website
rallveird

Joined: 13 Jun 2005
Posts: 31
:

Items
PostPosted: Mon Jun 13, 2005 4:00 am    Post subject: Reply with quote

If you put this sudoku (not symmetrical though) into the challenge-solver you get down to 56 to go. That's a lot of cells left.

Code:

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


(The sudoku can be found at http://www.menneske.no/sudoku/eng/showpuzzle.html?number=414834 )

Can anyone try it against the fishy cycles routine?
Back to top
View user's profile Send private message
vindaloo

Joined: 03 Jun 2005
Posts: 7
:

Items
PostPosted: Mon Jun 13, 2005 6:45 pm    Post subject: Re: What is trial by logic? Reply with quote

Hi Pete,
thanks for your reply. Sorry I didn't see it earlier.

I'm not a logic professor either, but I do have a mathematics/logic background. You raise a very interesting point - I was wondering why you thought example 2 was solvable by logic and Pappocom didn't.

Here is my thinking:
Just because a sudoku (or some other problem) only has one solution, does not (in and of itself) imply that it is solvable by logic. The proof that sudoku is NP-complete actually shows us that in general sudoku is *not* solvable by logic. In other words you can have a sudoku with only 1 solution, but there is no fast way of getting there - other than by searching.

Also the daily telegraph puzzles only have 1 solution (unless a mistake has been made which sometimes happens), yet they are not solvable using logic - search/backtracking must be employed.

I must give a major caveat to everything I have said though - it is that basically the discussions I have given are general. In general 1-solution sudoku puzzles are not solvable using logic. But that doesn't mean that in any particular case there isn't some rule out there which can solve it - just that in general it isn't true.

Vin.


PeteWake wrote:
Hi - I run the sudokusolver.co.uk site. Challenge puzzle 2 on the site is a great one because it noone has yet given the solve method that cracks it by logic. Yet we know it has a unique solution (try it on the main page with the 'check and guess' box checked and the 'return first' solution unchecked).

Sudoku puzzles fall into a class of problems mathemeticians call 'NP-hard' - which means that noone has yet found a way of solving every option by logic alone. However, the other way of looking at this (I think) is that there is an unbounded set of logic rules. However I am not a logic professor so I can't say with 100% confidence that this is the case.

To me, the point at which logic is left behind and guesswork begins is very clear - it is the point at which my program has to save a snapshot of the grid, reduce one gridpoint to one of the remaining possibilities and continue knowing it might have to come back.

I am now just keen for some earnest programmers to submit javascript code to solve method E.. which I don't think is guessing.

Happy sudokuing,
Pete Wake
Back to top
View user's profile Send private message
Doug

Joined: 28 May 2005
Posts: 42
:

Items
PostPosted: Mon Jun 13, 2005 9:20 pm    Post subject: Reply with quote

I have a couple of comments. (And yes, I am a professional methematician.)

Technically speaking, in usual mathematical usage, all Sudoku is solvable by logic. Backtracking is logic. Even the longest brute force backtracking algorithm, such as trying a value in a cell, trying a new value in the next and so on till all possible values have been tried in all cells is a logic solution.

What is meant by "logic" in this forum is more the problem of finding fast algorithms which don't use a lot of memory. (That way the method of solving can be carried out by a person with only pencil and paper in a reasonable time.) What is saught here are computationally easy solutions. Guess and check is still logic in the mathematical sense. People are really searching for solutions of low computational complexity.

Now as the NP-hard means that as the board sizes get larger, 9x9, 15x15, 18x18,... NxN, ...., the percent of boards where such fast algorithms give rapid solutions will peter out and more nasty algorithms will be needed. That means that the complexity of the rules must increase as board sizes get larger. Eventually, the rules must get so hard that they will not be doable by hand, by the lonely human.

The interesting question is: for 9x9, how computationally complex do the solution techniques have to get? Can we find a set of rules which avoids "guess and check", and is doable by hand? My guess is that there are boards, which already may be known, which require rules that are too complex to be done by hand. Even so, at 9x9, the 10 or so "rules" that are used by the "logic" solvers do a good job on most boards. The question is can we get them all easily. My guess is no.

Also, looking for these fast algorithms is a bit interesting from the point of view of finding better approaches to NP-hard problems.

Incidentally, the problem of finding a solution to a particular sudoku, of size NxN, while NP-hard, has an easy check, so it's NP-complete. (The check of a putative solution runs really fast-- in polynomial time.) I think the problem of finding all solutions, (assuming we don't know existence or uniqueness) is probably NP-hard, but not NP-complete.

Oh, and one more thing. "Guess and check" is used very carelessly here. Technically, all the methods used can be viewed as guess and check. Take the simple rule: "only one possible cell in a row". This rule is the same as saying "Can 1 go in cell 1? No. Can 1 go in cell 2? No. Can 1 go in cell 3? No. And so on until it's found that 1 can only go in cell 8, say." (But you need to check cell 9 to make sure cell 8 is the only possability.) It's just easy to visually scan and do that guess and check by eye. Sorry to say, but logically speaking it's still guess and check. Just one that's easy to do by hand; one that "runs" quickly. The phrase "guess and check" as used here is ill-defined. Again, what people are looking for are rules of low computational complexity.

I hope that clarifies some things a bit.
_________________
Doug Bowman
www.flickr.com/photos/bistrosavage
Back to top
View user's profile Send private message Send e-mail
MadOverlord

Joined: 01 Jun 2005
Posts: 80
:
Location: Wilmington, NC, USA

Items
PostPosted: Wed Jun 15, 2005 5:13 am    Post subject: Reply with quote

rallveird wrote:
Code:

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




The puzzle doesn't need Fishy Cycles; it can be solved with Nishio. In fact, with Nishio disabled Fishy Cycles doesn't help it.

Code:
Deducing...
Deduction pass 1; 21 squares solved; 60 remaining.

* R3C2 can only be <7>.

Deduction pass 2; 22 squares solved; 59 remaining.

* R6C4 is the only square in column 4 that can be
  a <4>.  It is thus pinned to that value.

Deduction pass 3; 23 squares solved; 58 remaining.

* R8C1 is the only square in block 7 that can be
  a <6>.  It is thus pinned to that value.

Deduction pass 4; 24 squares solved; 57 remaining.

* Intersection of row 3 with block 1.
  The non-intersecting squares of the block
  cannot contain the values <9>.

   R2C1 - removing <9> from <12459> leaving <1245>.

Deduction pass 5; 24 squares solved; 57 remaining.

* Intersection of row 3 with block 3.
  The non-intersecting squares of the block
  cannot contain the values <6>.

   R1C8 - removing <6> from <145678> leaving <14578>.
   R1C9 - removing <6> from <25678> leaving <2578>.

Deduction pass 6; 24 squares solved; 57 remaining.

* Intersection of row 6 with block 6.
  The non-intersecting squares of the block
  cannot contain the values <6>.

   R4C8 - removing <6> from <1568> leaving <158>.
   R4C9 - removing <6> from <3568> leaving <358>.
   R5C7 - removing <6> from <13568> leaving <1358>.
   R5C8 - removing <6> from <15689> leaving <1589>.

Deduction pass 7; 24 squares solved; 57 remaining.

* R7C8 is the only square in column 8 that can be
  a <6>.  It is thus pinned to that value.

Deduction pass 8; 25 squares solved; 56 remaining.

* A set of 2 squares can be constrained.
  The following squares share possibilities <79>:

   R7C9
   R9C8

  No other squares in block 9 have those
  possibilities.  Thus, any additional possibilties
  they have can be eliminated.

   R7C9 - removing <23> from <2379> leaving <79>.
   R9C8 - removing <458> from <45789> leaving <79>.

Deduction pass 9; 25 squares solved; 56 remaining.

* Intersection of column 8 with block 3.
  The non-intersecting squares of the block
  cannot contain the values <4>.

   R2C7 - removing <4> from <12458> leaving <1258>.

Deduction pass 10; 25 squares solved; 56 remaining.

* Intersection of block 7 with column 3.
  The non-intersecting squares of the column
  cannot contain the values <1>.

   R1C3 - removing <1> from <12458> leaving <2458>.
   R4C3 - removing <1> from <12345> leaving <2345>.
   R5C3 - removing <1> from <13579> leaving <3579>.
   R6C3 - removing <1> from <1359> leaving <359>.

Deduction pass 11; 25 squares solved; 56 remaining.

* Found a Nishio contradiction.  After 3 cycles,
  it became clear that R4C8 could not be a <1>.

   R4C8 - removing <1> from <158> leaving <58>.

  Here is a trace of the Nishio matrix as it was simplified.

   # = Squares that must be <1>.
   O = squares that can be a <1>.
   X = the current square (also an "O").
   . = squares that cannot be <1>.
   - = squares that were invalidated in the previous cycle.
   P = the square that invalidated them (also a "#").
   @ = the invalid block that cannot contain a <1>.

  Nishio cycle 1 on <1> at R4C8

   O . . . . . . O .
   O O . . . . O O .
   . . . . . # . . .
   O O . . O . . X .
   O O . O O . O O .
   O . . . . . O . .
   . . O O O . . . .
   . . O . O . . . .
   . . . . . . . . #

  Nishio cycle 2 on <1> at R2C7

   O . . . . . . - .
   O O . . . . X - .
   . . . . . # . - .
   - - - - - - - P -
   O O . O O . - - -
   O . . . . . - - -
   . . O O O . . - .
   . . O . O . . - .
   . . . . . . . - #

  Nishio cycle 3 on <1> at R1C1

   X . . . . . - - -
   - - - - - - P - -
   . . . . . # - - -
   . . . . . . - # .
   O O . O O . - . .
   O . . . . . - . .
   . . O O O . - . .
   . . O . O . - . .
   . . . . . . - . #

  Final State:

   P - - - - - - - -
   - - - . . . # . .
   - - - . . # . . .
   - . . . . . . # .
   - O . O O . . . .
   @ @ @ @ @ @ @ @ @
   - . O O O . . . .
   - . O . O . . . .
   - . . . . . . . #

Deduction pass 12; 25 squares solved; 56 remaining.

* 2 squares in column 8 form a simple locked pair.
  The following squares share possibilities <58>:

   R4C8
   R8C8

  Thus, possibilities <58> can be removed from
  the rest of the column.

   R1C8 - removing <58> from <14578> leaving <147>.
   R2C8 - removing <58> from <14578> leaving <147>.
   R5C8 - removing <58> from <1589> leaving <19>.

Deduction pass 13; 25 squares solved; 56 remaining.

* 3 squares in row 4 form a locked triplet.
  R4C6<358> R4C8<58> R4C9<358> share possibilities <358>.
  These can be excluded from the rest of the row.

   R4C1 - removing <35> from <12345> leaving <124>.
   R4C3 - removing <35> from <2345> leaving <24>.
   R4C5 - removing <358> from <13568> leaving <16>.

Deduction pass 14; 25 squares solved; 56 remaining.

* Found a Nishio contradiction.  After 5 cycles,
  it became clear that R5C8 could not be a <1>.

   R5C8 - removing <1> from <19> leaving <9>.

  Here is a trace of the Nishio matrix as it was simplified.

   # = Squares that must be <1>.
   O = squares that can be a <1>.
   X = the current square (also an "O").
   . = squares that cannot be <1>.
   - = squares that were invalidated in the previous cycle.
   P = the square that invalidated them (also a "#").
   @ = the invalid block that cannot contain a <1>.

  Nishio cycle 1 on <1> at R5C8

   O . . . . . . O .
   O O . . . . O O .
   . . . . . # . . .
   O O . . O . . . .
   O O . O O . O X .
   O . . . . . O . .
   . . O O O . . . .
   . . O . O . . . .
   . . . . . . . . #

  Nishio cycle 2 on <1> at R4C5

   O . . . . . . - .
   O O . . . . O - .
   . . . . . # . - .
   O O . . X . - - -
   - - - - - - - P -
   O . . . . . - - -
   . . O O O . . - .
   . . O . O . . - .
   . . . . . . . - #

  Nishio cycle 3 on <1> at R7C4

   O . . . - . . . .
   O O . . - . O . .
   . . . . - # . . .
   - - - - P - - - -
   . . . - - - . # .
   O . . - - - . . .
   . . O X - . . . .
   . . O . - . . . .
   . . . . - . . . #

  Nishio cycle 4 on <1> at R8C3

   O . . - . . . . .
   O O . - . . O . .
   . . . - . # . . .
   . . . - # . . . .
   . . . - . . . # .
   O . . - . . . . .
   - - - P - - - - -
   . . X - - - . . .
   . . . - - - . . #

  Nishio cycle 5 on <1> at R6C1

   O . - . . . . . .
   O O - . . . O . .
   . . - . . # . . .
   . . - . # . . . .
   . . - . . . . # .
   X . - . . . . . .
   - - - # . . . . .
   - - P - - - - - -
   - - - . . . . . #

  Final State:

   @ @ @ @ @ @ @ @ @
   - O . . . . O . .
   - . . . . # . . .
   - - - . # . . . .
   - - - . . . . # .
   P - - - - - - - -
   - . . # . . . . .
   - . # . . . . . .
   - . . . . . . . #

* Reconstraining R9C8 fixes its value at <7>.
* Reconstraining R7C9 fixes its value at <9>.

* Reconstraining R7C6 fixes its value at <3>.

* Reconstraining R7C4 fixes its value at <1>.
* Reconstraining R6C6 fixes its value at <5>.

* Reconstraining R4C6 fixes its value at <8>.
* Reconstraining R7C5 fixes its value at <2>.
* Reconstraining R7C7 fixes its value at <4>.
* Reconstraining R7C3 fixes its value at <7>.

* Reconstraining R1C6 fixes its value at <7>.
* Reconstraining R4C8 fixes its value at <5>.
* Reconstraining R4C9 fixes its value at <3>.
* Reconstraining R8C8 fixes its value at <8>.
* Reconstraining R6C9 fixes its value at <6>.
* Reconstraining R6C7 fixes its value at <1>.
* Reconstraining R8C5 fixes its value at <5>.

* Reconstraining R2C6 fixes its value at <9>.
* Reconstraining R5C7 fixes its value at <8>.
* Reconstraining R9C4 fixes its value at <8>.
* Reconstraining R8C9 fixes its value at <2>.
* Reconstraining R8C7 fixes its value at <3>.
* Reconstraining R9C5 fixes its value at <9>.

* Reconstraining R8C3 fixes its value at <1>.
* Reconstraining R9C7 fixes its value at <5>.
* Reconstraining R2C7 fixes its value at <2>.
* Reconstraining R3C7 fixes its value at <6>.

Deduction pass 15; 52 squares solved; 29 remaining.

* R2C9 is the only square in row 2 that can be
  a <7>.  It is thus pinned to that value.

Deduction pass 16; 53 squares solved; 28 remaining.

* R2C5 is the only square in row 2 that can be
  a <8>.  It is thus pinned to that value.

* Reconstraining R1C5 fixes its value at <6>.

* Reconstraining R1C4 fixes its value at <5>.
* Reconstraining R4C5 fixes its value at <1>.
* Reconstraining R5C5 fixes its value at <3>.
* Reconstraining R5C3 fixes its value at <5>.
* Reconstraining R5C4 fixes its value at <6>.

* Reconstraining R2C4 fixes its value at <3>.
* Reconstraining R1C9 fixes its value at <8>.
* Reconstraining R3C9 fixes its value at <5>.
* Reconstraining R3C1 fixes its value at <9>.
* Reconstraining R5C2 fixes its value at <1>.

* Reconstraining R3C3 fixes its value at <8>.
* Reconstraining R6C1 fixes its value at <3>.
* Reconstraining R5C1 fixes its value at <7>.
* Reconstraining R2C2 fixes its value at <4>.
* Reconstraining R6C3 fixes its value at <9>.

* Reconstraining R1C3 fixes its value at <2>.
* Reconstraining R2C8 fixes its value at <1>.
* Reconstraining R9C2 fixes its value at <2>.
* Reconstraining R2C1 fixes its value at <5>.
* Reconstraining R1C8 fixes its value at <4>.
* Reconstraining R9C1 fixes its value at <4>.
* Reconstraining R4C2 fixes its value at <6>.

* Reconstraining R1C1 fixes its value at <1>.
* Reconstraining R4C3 fixes its value at <4>.
* Reconstraining R4C1 fixes its value at <2>.
* Reconstraining R9C3 fixes its value at <3>.

Deduction pass 17; 81 squares solved; 0 remaining.

Solution found!
Deduction completed...

Back to top
View user's profile Send private message Visit poster's website AIM Address
tilps

Joined: 19 Jun 2005
Posts: 44
:

Items
PostPosted: Sun Jun 19, 2005 7:21 am    Post subject: Reply with quote

hrmm, first order 'lookahead created' logic solves the second challenge problem here as well. Guess I should have a look at how.
Back to top
View user's profile Send private message
jiffle

Joined: 21 Jun 2005
Posts: 3
:

Items
PostPosted: Tue Jun 21, 2005 5:05 pm    Post subject: Reply with quote

Hi, please could somebody tell me how to solve the following using logic:

Code:

8.3|.29|716
..6|.18|5.4
...|.6.|..8
---+---+---
..5|.46|.8.
7.9|.35|642
.6.|.9.|1.5
---+---+---
6..|.7.|.51
..1|65.|8..
5..|981|463


My software gives up with the following:

Code:
R    1   2   3      4   5   6      7   8   9

    888 ... 333  | ... 222 999  | 777 111 666
r1  888 45. 333  | 45. 222 999  | 777 111 666      ...45....
    888 ... 333  | ... 222 999  | 777 111 666
                 |              |
    .2. .2. 666  | ..3 111 888  | 555 .23 444
r2  ... ... 666  | ... 111 888  | 555 ... 444      .23...7.9
    ..9 7.9 666  | 7.. 111 888  | 555 ..9 444
                 |              |
    12. 12. .2.  | ..3 666 ..3  | .23 .23 888
r3  4.. 45. 4..  | 45. 666 4..  | ... ... 888      12345.7.9
    ..9 7.9 7..  | 7.. 666 7..  | ..9 ..9 888
                 |              |
    (12.45.7.9)  | (..345.7..)  | (.23.....9)
                 |              |
   ----+---+-----R----+---+-----R----+---+----
                 |              |
    123 123 555  | 12. 444 666  | ..3 888 ...
r4  ... ... 555  | ... 444 666  | ... 888 ...      123...7.9
    ... ... 555  | 7.. 444 666  | ..9 888 7.9
                 |              |
    777 1.. 999  | 1.. 333 555  | 666 444 222
r5  777 ... 999  | ... 333 555  | 666 444 222      1......8.
    777 .8. 999  | .8. 333 555  | 666 444 222
                 |              |
    .23 666 .2.  | .2. 999 .2.  | 111 ..3 555
r6  4.. 666 4..  | ... 999 ...  | 111 ... 555      .234..78.
    ... 666 .8.  | 78. 999 7..  | 111 7.. 555
                 |              |
    (1234...8.)  | (12....78.)  | (..3...7.9)
                 |              |
   ----+---+-----R----+---+-----R----+---+----
                 |              |
    666 ..3 ...  | .23 777 .23  | .2. 555 111
r7  666 4.. 4..  | 4.. 777 4..  | ... 555 111      .234...89
    666 .89 .8.  | ... 777 ...  | ..9 555 111
                 |              |
    ..3 ..3 111  | 666 555 .23  | 888 .2. ...
r8  4.. 4.. 111  | 666 555 4..  | 888 ... ...      .234..7.9
    ..9 ..9 111  | 666 555 ...  | 888 7.9 7.9
                 |              |
    555 .2. .2.  | 999 888 111  | 444 666 333
r9  555 ... ...  | 999 888 111  | 444 666 333      .2....7..
    555 7.. 7..  | 999 888 111  | 444 666 333
                 |              |
    (.234..789)  | (.234.....)  | (.2....7.9)
                 |              |
    123 123 .2.    123 ... .23    .23 .23 ...
    4.. 45. 4..    45. ... 4..    ... ... ...
    ..9 789 78.    78. ... 7..    ..9 7.9 7.9


I can turn on 'guessing' in which case it solves it with two guesses to be:

Code:

*c>123456789
r+++++++++++
r1=843529716
r2=976318524
r3=152764398
r4=315246987
r5=789135642
r6=264897135
r7=698473251
r8=431652879
r9=527981463


I'm looking for logic to apply to determine a solution, rather than any kind of 'reductio ad absurdum' (which my code already does through redriving a guess subroutine, and aborting if any inconsitences are found).

Incidentally (and maybe everybody does this) I applied some intelligence to my guessing. I toyed with storing state every time I have to make a guess within a guess (eg guessed one cell then got stuck and had to guess a second time in order to continue further) but that would have been tricky given the state of my code now (string and sticky tape). So I took the easy way out and stored state at the end of conventional logic, then redrive guessing from the start based on a predefined array of unfinished cells. The beauty is that I can sort that array based on different criteria, such as cardinality of candidates (ie guess 2-candidate cells before 3-candidate ones) and weighted value of the candidates (based on other criteria such as their frequency elsewhere in the grid).
Back to top
View user's profile Send private message
MadOverlord

Joined: 01 Jun 2005
Posts: 80
:
Location: Wilmington, NC, USA

Items
PostPosted: Tue Jun 21, 2005 7:08 pm    Post subject: Reply with quote

Solving it requires using Bowman Bingo techniques. Here's the solution path:

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

Note: Hints have been turned off to make it easier to verify the puzzle was scanned correctly.


Deducing the entire puzzle...
Deduction pass 1; 44 squares solved; 37 remaining.

* 2 squares in block 7 form a simple locked pair.
  The following squares share possibilities <27>:

   R9C2
   R9C3

  Thus, possibilities <27> can be removed from
  the rest of the block.

   R7C2 - removing <2> from <23489> leaving <3489>.
   R7C3 - removing <2> from <248> leaving <48>.
   R8C1 - removing <2> from <2349> leaving <349>.
   R8C2 - removing <27> from <23479> leaving <349>.

Deduction pass 2; 44 squares solved; 37 remaining.

* Found a contradiction by Bowman Bingo.  After 2
  cycles, it became clear that R3C2 could not be a
  <2>, because this would force both R2C1 and
  R2C2 to be <9>.

  As they are in the same row, this is not possible.

   R3C2 - removing <2> from <124579> leaving <14579>.

  Here is a trace of the Bowman matrix as it developed.

   X = the current square (also an "C").
   C = squares with chips on them.
   . = squares that can still have more than one value.

  Bowman cycle 1:

   8 . 3 . 2 9 7 1 6
   . . 6 . 1 8 5 . 4
   . X . . 6 . . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R3C2 setting its value to <2>.

   Placed a <7> chip on R9C2 (forced).
   Placed a <9> chip on R2C1 (forced).
   Placed a <1> chip on R3C1 (pinned).
   Placed a <5> chip on R3C4 (pinned).
   Placed a <5> chip on R1C2 (pinned).

  Bowman cycle 2:

   8 C 3 . 2 9 7 1 6
   C . 6 . 1 8 5 . 4
   C 2 . C 6 . . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 X . 9 8 1 4 6 3

  Flipped chip at R9C2 setting its value to <7>.

   Placed a <2> chip on R9C3 (forced).
   Placed a <9> chip on R2C2 (forced).

  Final state:

   8 . 3 . 2 9 7 1 6
   9 9 6 . 1 8 5 . 4
   . 2 . . 6 . . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 7 2 9 8 1 4 6 3

  Both R2C1 and R2C2 are <9>.

Deduction pass 3; 44 squares solved; 37 remaining.

* Found a contradiction by Bowman Bingo.  After 3
  cycles, it became clear that R3C6 could not be a
  <3>, because this would force both R2C8 and
  R6C8 to be <3>.

  As they are in the same column, this is not possible.

   R3C6 - removing <3> from <347> leaving <47>.

  Here is a trace of the Bowman matrix as it developed.

   X = the current square (also an "C").
   C = squares with chips on them.
   . = squares that can still have more than one value.

  Bowman cycle 1:

   8 . 3 . 2 9 7 1 6
   . . 6 . 1 8 5 . 4
   . . . . 6 X . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R3C6 setting its value to <3>.

   Placed a <7> chip on R2C4 (forced).
   Placed a <7> chip on R6C6 (pinned).

  Bowman cycle 2:

   8 . 3 . 2 9 7 1 6
   . . 6 X 1 8 5 . 4
   . . . . 6 3 . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 C 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R2C4 setting its value to <7>.

   Placed a <3> chip on R2C8 (pinned).
   Placed a <3> chip on R7C4 (pinned).

  Bowman cycle 3:

   8 . 3 . 2 9 7 1 6
   . . 6 7 1 8 5 C 4
   . . . . 6 3 . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 X 1 . 5
   6 . . C 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R6C6 setting its value to <7>.

   Placed a <3> chip on R6C8 (forced).

  Final state:

   8 . 3 . 2 9 7 1 6
   . . 6 7 1 8 5 . 4
   . . . . 6 3 . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 7 1 3 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Both R2C8 and R6C8 are <3>.

Deduction pass 4; 44 squares solved; 37 remaining.

* Intersection of column 6 with block 8.
  The non-intersecting squares of the block
  cannot contain the values <3>.

   R7C4 - removing <3> from <234> leaving <24>.

Deduction pass 5; 44 squares solved; 37 remaining.

* Found a contradiction by Bowman Bingo.  After 2
  cycles, it became clear that R3C2 could not be a
  <7>, because this would force both R3C4 and
  R1C4 to be <5>.

  As they are in the same column, this is not possible.

   R3C2 - removing <7> from <14579> leaving <1459>.

  Here is a trace of the Bowman matrix as it developed.

   X = the current square (also an "C").
   C = squares with chips on them.
   . = squares that can still have more than one value.

  Bowman cycle 1:

   8 . 3 . 2 9 7 1 6
   . . 6 . 1 8 5 . 4
   . X . . 6 . . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R3C2 setting its value to <7>.

   Placed a <4> chip on R3C6 (forced).
   Placed a <2> chip on R9C2 (forced).
   Placed a <1> chip on R3C1 (pinned).
   Placed a <5> chip on R3C4 (pinned).
   Placed a <5> chip on R1C2 (pinned).

  Bowman cycle 2:

   8 C 3 . 2 9 7 1 6
   . . 6 . 1 8 5 . 4
   C 7 . C 6 X . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 C . 9 8 1 4 6 3

  Flipped chip at R3C6 setting its value to <4>.

   Placed a <2> chip on R3C3 (forced).
   Placed a <5> chip on R1C4 (forced).
   Placed a <7> chip on R6C6 (pinned).
   Placed a <7> chip on R2C4 (pinned).

  Final state:

   8 . 3 5 2 9 7 1 6
   . . 6 . 1 8 5 . 4
   . 7 2 . 6 4 . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 2 . 9 8 1 4 6 3

  Both R3C4 and R1C4 are <5>.

Deduction pass 6; 44 squares solved; 37 remaining.

* Found a contradiction by Bowman Bingo.  After 3
  cycles, it became clear that R2C4 could not be a
  <7>, because this would force both R6C6 and
  R6C8 to be <7>.

  As they are in the same row, this is not possible.

   R2C4 - removing <7> from <37> leaving <3>.

  Here is a trace of the Bowman matrix as it developed.

   X = the current square (also an "C").
   C = squares with chips on them.
   . = squares that can still have more than one value.

  Bowman cycle 1:

   8 . 3 . 2 9 7 1 6
   . . 6 X 1 8 5 . 4
   . . . . 6 . . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R2C4 setting its value to <7>.

   Placed a <4> chip on R3C6 (forced).
   Placed a <3> chip on R2C8 (pinned).
   Placed a <3> chip on R3C4 (pinned).

  Bowman cycle 2:

   8 . 3 . 2 9 7 1 6
   . . 6 7 1 8 5 C 4
   . . . C 6 X . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R3C6 setting its value to <4>.

   Placed a <5> chip on R1C4 (forced).
   Placed a <7> chip on R3C3 (pinned).
   Placed a <7> chip on R6C6 (pinned).

  Bowman cycle 3:

   8 . 3 C 2 9 7 1 6
   . . 6 7 1 8 5 X 4
   . . C C 6 4 . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 C 1 . 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Flipped chip at R2C8 setting its value to <3>.

   Placed a <7> chip on R6C8 (forced).

  Final state:

   8 . 3 5 2 9 7 1 6
   . . 6 7 1 8 5 3 4
   . . . . 6 4 . . 8
   . . 5 . 4 6 . 8 .
   7 . 9 . 3 5 6 4 2
   . 6 . . 9 . 1 7 5
   6 . . . 7 . . 5 1
   . . 1 6 5 . 8 . .
   5 . . 9 8 1 4 6 3

  Both R6C6 and R6C8 are <7>.

Deduction pass 7; 45 squares solved; 36 remaining.

* R2C2 is the only square in row 2 that can be
  a <7>.  It is thus pinned to that value.

* Reconstraining R9C2 fixes its value at <2>.
* Reconstraining R9C3 fixes its value at <7>.

Deduction pass 8; 48 squares solved; 33 remaining.

* Found a Nishio contradiction.  After 4 cycles,
  it became clear that R6C6 could not be a <2>.

   R6C6 - removing <2> from <27> leaving <7>.

  Here is a trace of the Nishio matrix as it was simplified.

   # = Squares that must be <2>.
   O = squares that can be a <2>.
   X = the current square (also an "O").
   . = squares that cannot be <2>.
   - = squares that were invalidated in the previous cycle.
   P = the square that invalidated them (also a "#").
   @ = the invalid group that cannot contain a <2>.

  Nishio cycle 1 on <2> at R6C6

   . . . . # . . . .
   O . . . . . . O .
   O . O . . . O O .
   O . . O . . . . .
   . . . . . . . . #
   O . O O . X . . .
   . . . O . O O . .
   . . . . . O . O .
   . # . . . . . . .

  Nishio cycle 2 on <2> at R7C4

   . . . . # - . . .
   O . . . . - . O .
   O . O . . - O O .
   O . . - - - . . .
   . . . - - - . . #
   - - - - - P - - -
   . . . X . - O . .
   . . . . . - . O .
   . # . . . - . . .

  Nishio cycle 3 on <2> at R8C8

   . . . - # . . . .
   O . . - . . . O .
   O . O - . . O O .
   O . . - . . . . .
   . . . - . . . . #
   . . . - . # . . .
   - - - P - - - - -
   . . . - - - . X .
   . # . - - - . . .

  Nishio cycle 4 on <2> at R4C1

   . . . . # . . - .
   O . . . . . . - .
   O . O . . . O - .
   X . . . . . . - .
   . . . . . . . - #
   . . . . . # . - .
   . . . # . . - - -
   - - - - - - - P -
   . # . . . . - - -

  Final State:

   - . . . # . . . .
   @ @ @ @ @ @ @ @ @
   - . O . . . O . .
   P - - - - - - - -
   - - - . . . . . #
   - - - . . # . . .
   - . . # . . . . .
   - . . . . . . # .
   - # . . . . . . .

* Reconstraining R3C6 fixes its value at <4>.
* Reconstraining R6C8 fixes its value at <3>.
* Reconstraining R4C7 fixes its value at <9>.

* Reconstraining R1C4 fixes its value at <5>.
* Reconstraining R3C3 fixes its value at <2>.
* Reconstraining R4C9 fixes its value at <7>.
* Reconstraining R7C7 fixes its value at <2>.
* Reconstraining R8C9 fixes its value at <9>.
* Reconstraining R3C7 fixes its value at <3>.
* Reconstraining R7C4 fixes its value at <4>.
* Reconstraining R7C6 fixes its value at <3>.
* Reconstraining R8C8 fixes its value at <7>.

* Reconstraining R1C2 fixes its value at <4>.
* Reconstraining R3C4 fixes its value at <7>.
* Reconstraining R2C1 fixes its value at <9>.
* Reconstraining R3C8 fixes its value at <9>.
* Reconstraining R3C1 fixes its value at <1>.
* Reconstraining R2C8 fixes its value at <2>.
* Reconstraining R7C3 fixes its value at <8>.
* Reconstraining R8C6 fixes its value at <2>.

* Reconstraining R8C2 fixes its value at <3>.
* Reconstraining R3C2 fixes its value at <5>.
* Reconstraining R7C2 fixes its value at <9>.
* Reconstraining R6C3 fixes its value at <4>.
* Reconstraining R8C1 fixes its value at <4>.
* Reconstraining R4C2 fixes its value at <1>.

* Reconstraining R4C4 fixes its value at <2>.
* Reconstraining R5C2 fixes its value at <8>.
* Reconstraining R4C1 fixes its value at <3>.
* Reconstraining R6C4 fixes its value at <8>.
* Reconstraining R5C4 fixes its value at <1>.
* Reconstraining R6C1 fixes its value at <2>.

Deduction pass 9; 81 squares solved; 0 remaining.

Solution found!


This is one of the nastier puzzles I've run into, congrats.

Bowman Bingo will solve any puzzle AFAICT, because it is effectively a human-runnable recursion method. Amusingly, Doug Bowman is using it to find new, simpler deductive patterns.
Back to top
View user's profile Send private message Visit poster's website AIM Address
jiffle

Joined: 21 Jun 2005
Posts: 3
:

Items
PostPosted: Tue Jun 21, 2005 7:24 pm    Post subject: Reply with quote

Thanks. Interesting to read about Bowman Bingo. My code solved it too, although not entirely with pure logic, and that's why I was wondering whether I was missing something. My code makes 'intelligent' guesses and aborts them when inconsistencies are detected (although the debug output is nowhere near as sophisticated as that shown above... it usually just sets an error flag when an out-of-range condition arises from a matrix operation [eg due to no candidates being found], at which point it aborts the current pass and redrives guessing from the next entry in the guess array). The inconsistency detection is rather more by luck than judgement although it seems to hand together suprisingly well!
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