to rubylips

Advanced methods and approaches for solving Sudoku puzzles

to rubylips

Postby bennys » Tue Nov 29, 2005 6:03 am

How come your solver have problem with that puzzle?
I get "Chain length exceeds 15"

Code: Select all
Puzzle: Menneske.no Very Hard #3338282
+-------+-------+-------+
| . . 1 | 4 5 . | . . 3 |
| . . . | . 7 8 | 2 . . |
| 7 . . | . 9 . | 5 . 6 |
+-------+-------+-------+
| . . 9 | 7 1 3 | 4 5 2 |
| 4 . 2 | 9 6 5 | 8 . 7 |
| . 7 . | 2 8 4 | 6 . . |
+-------+-------+-------+
| . 4 . | . 3 9 | . . 5 |
| . . . | . 4 7 | . . . |
| 9 . 7 | 5 2 . | 3 . . |
+-------+-------+-------+

+----------------------+----------------------+----------------------+
| 268    2689   1      | 4      5      26     | 79     789    3      |
| 356    3569   3456   | 136    7      8      | 2      149    149    |
| 7      238    348    | 13     9      12     | 5      148    6      |
+----------------------+----------------------+----------------------+
| 68     68     9      | 7      1      3      | 4      5      2      |
| 4      13     2      | 9      6      5      | 8      13     7      |
| 135    7      35     | 2      8      4      | 6      139    19     |
+----------------------+----------------------+----------------------+
| 1268   4      68     | 168    3      9      | 17     267    5      |
| 123568 123568 3568   | 168    4      7      | 19     269    89     |
| 9     *168    7      | 5      2      16     | 3      46     48     |
+----------------------+----------------------+----------------------+

R9C2<>8 =>R9C9=8 =>R8C9=9 =>R6C9=1=>R5C8=3 =>R5C2=1 =>R9C2<>1
and it solve the puzzle(using uniqueness later).
bennys
 
Posts: 156
Joined: 28 September 2005

Re: to rubylips

Postby rubylips » Tue Nov 29, 2005 12:52 pm

bennys wrote:How come your solver have problem with that puzzle?
I get "Chain length exceeds 15"

It's not necessary to know the precise route taken by a chain in order to make inferences from it - ultimately, the solver stores the chain end-points, its end-values and the logical truth table that will apply should a given end-point store a given end-value. The route is merely presented as a convenience to the user. When the solver is run in command-line mode with verbose output disabled, the solver doesn't bother to store the route taken by each chain. However, since it takes quite a lot of memory to store each route, an upper limit is placed on the stored route length. Chains that exceed this length will still be processed - it's just that the solver won't be able to write out the chain.

I've updated the solver since the most recent release. The log for the first move now reads as follows:
Code: Select all
Consider the cell r7c1.
When it contains the value 2, the values 6 and 8 in Column 1 must occupy the cells r1c1 and r4c1 in some order.
When it contains the value 1, the values 6 and 8 in Box 7 must occupy the cells r7c3 and r9c2 in some order.
Whichever value it contains, the cells r8c1 and r9c1 cannot contain the values 6 or 8.
- The moves r8c1:=6 and r8c1:=8 have been eliminated.
Consider the chain r8c4~1~r8c7+<1|4>+r9c9+<8|6>+r9c8+<4|1>+r9c6.
When the cell r8c4 contains the value 1, so does the cell r9c6 - a contradiction.
Therefore, the cell r8c4 cannot contain the value 1.
- The move r8c4:=1 has been eliminated.
Consider the chain r3c2~8~r9c2-8-r9c9-4-r9c8+<6|8>+r3c8.
When the cell r3c2 contains the value 8, so does the cell r3c8 - a contradiction.
Therefore, the cell r3c2 cannot contain the value 8.
- The move r3c2:=8 has been eliminated.
The values 4 and 8 occupy the cells r3c3 and r3c8 in some order.
- The moves r3c3:=3 and r3c8:=1 have been eliminated.
The value 1 in Box 2 must lie in Row 3.
- The move r2c4:=1 has been eliminated.
Consider the chain r3c2=3=r2c4=6=r9c6-1-r9c2.
The cells r3c2 and r9c2 contain one value from the set {3,1} and another from {2,6,8}.
The values 3 and 1 occupy two of the cells r3c2, r9c2 and r5c2 in some order.
- The moves r2c2:=3, r8c2:=3 and r8c2:=1 have been eliminated.
Consider the chain r5c2-1-r5c8~1~r6c9+<1|8>+r8c9+<9|4>+r9c9-8-r9c2.
When the cell r9c2 contains the value 1, some other value must occupy the cell r5c2, which means that the value 8 must occupy the cell r9c2 - a contradiction.
Therefore, the cell r9c2 cannot contain the value 1.
- The move r9c2:=1 has been eliminated.
The cell r9c6 is the only candidate for the value 1 in Row 9.

Since the solver seeks short chains rather than critical chains, it reports several. Your chain is the last reported.

The trivial moves that follow this tricky first move lead to the following candidate grid:
Code: Select all
      2|8  2|9    1 |    4  5  6 |  7|9  7|8|9      3
      5|6  5|9  4|6 |    3  7  8 |    2  1|4|9  1|4|9
        7    3  4|8 |    1  9  2 |    5    4|8      6
--------------------+------------+-------------------
      6|8  6|8    9 |    7  1  3 |    4      5      2
        4    1    2 |    9  6  5 |    8      3      7
      3|5    7  3|5 |    2  8  4 |    6    1|9    1|9
--------------------+------------+-------------------
      1|2    4  6|8 |  6|8  3  9 |  1|7    2|7      5
  1|2|3|5  2|5  3|5 |  6|8  4  7 |  1|9  2|6|9    8|9
        9  6|8    7 |    5  2  1 |    3    4|6    4|8

whereupon the solver reports:
Code: Select all
Consider the chain r1c1+<8|1>+r7c1-2-r7c8-7-r1c8.
When the cell r1c8 contains the value 8, some other value must occupy the cell r1c1, which means that the value 7 must occupy the cell r1c8 - a contradiction.
Therefore, the cell r1c8 cannot contain the value 8.
- The move r1c8:=8 has been eliminated.
The cell r1c1 is the only candidate for the value 8 in Row 1.
rubylips
 
Posts: 149
Joined: 01 November 2005

Re: to rubylips

Postby ctettam9 » Tue Nov 29, 2005 11:55 pm

Did you write a solver/helper program (the stuff in the "code" section) and is it available to download? And if you didn't, do you know who did?


Chris

rubylips wrote:
bennys wrote:How come your solver have problem with that puzzle?
I get "Chain length exceeds 15"

It's not necessary to know the precise route taken by a chain in order to make inferences from it - ultimately, the solver stores the chain end-points, its end-values and the logical truth table that will apply should a given end-point store a given end-value. The route is merely presented as a convenience to the user. When the solver is run in command-line mode with verbose output disabled, the solver doesn't bother to store the route taken by each chain. However, since it takes quite a lot of memory to store each route, an upper limit is placed on the stored route length. Chains that exceed this length will still be processed - it's just that the solver won't be able to write out the chain.

I've updated the solver since the most recent release. The log for the first move now reads as follows:
Code: Select all
Consider the cell r7c1.
When it contains the value 2, the values 6 and 8 in Column 1 must occupy the cells r1c1 and r4c1 in some order.
When it contains the value 1, the values 6 and 8 in Box 7 must occupy the cells r7c3 and r9c2 in some order.
Whichever value it contains, the cells r8c1 and r9c1 cannot contain the values 6 or 8.
- The moves r8c1:=6 and r8c1:=8 have been eliminated.
Consider the chain r8c4~1~r8c7+<1|4>+r9c9+<8|6>+r9c8+<4|1>+r9c6.
When the cell r8c4 contains the value 1, so does the cell r9c6 - a contradiction.
Therefore, the cell r8c4 cannot contain the value 1.
- The move r8c4:=1 has been eliminated.
Consider the chain r3c2~8~r9c2-8-r9c9-4-r9c8+<6|8>+r3c8.
When the cell r3c2 contains the value 8, so does the cell r3c8 - a contradiction.
Therefore, the cell r3c2 cannot contain the value 8.
- The move r3c2:=8 has been eliminated.
The values 4 and 8 occupy the cells r3c3 and r3c8 in some order.
- The moves r3c3:=3 and r3c8:=1 have been eliminated.
The value 1 in Box 2 must lie in Row 3.
- The move r2c4:=1 has been eliminated.
Consider the chain r3c2=3=r2c4=6=r9c6-1-r9c2.
The cells r3c2 and r9c2 contain one value from the set {3,1} and another from {2,6,8}.
The values 3 and 1 occupy two of the cells r3c2, r9c2 and r5c2 in some order.
- The moves r2c2:=3, r8c2:=3 and r8c2:=1 have been eliminated.
Consider the chain r5c2-1-r5c8~1~r6c9+<1|8>+r8c9+<9|4>+r9c9-8-r9c2.
When the cell r9c2 contains the value 1, some other value must occupy the cell r5c2, which means that the value 8 must occupy the cell r9c2 - a contradiction.
Therefore, the cell r9c2 cannot contain the value 1.
- The move r9c2:=1 has been eliminated.
The cell r9c6 is the only candidate for the value 1 in Row 9.

Since the solver seeks short chains rather than critical chains, it reports several. Your chain is the last reported.

The trivial moves that follow this tricky first move lead to the following candidate grid:
Code: Select all
      2|8  2|9    1 |    4  5  6 |  7|9  7|8|9      3
      5|6  5|9  4|6 |    3  7  8 |    2  1|4|9  1|4|9
        7    3  4|8 |    1  9  2 |    5    4|8      6
--------------------+------------+-------------------
      6|8  6|8    9 |    7  1  3 |    4      5      2
        4    1    2 |    9  6  5 |    8      3      7
      3|5    7  3|5 |    2  8  4 |    6    1|9    1|9
--------------------+------------+-------------------
      1|2    4  6|8 |  6|8  3  9 |  1|7    2|7      5
  1|2|3|5  2|5  3|5 |  6|8  4  7 |  1|9  2|6|9    8|9
        9  6|8    7 |    5  2  1 |    3    4|6    4|8

whereupon the solver reports:
Code: Select all
Consider the chain r1c1+<8|1>+r7c1-2-r7c8-7-r1c8.
When the cell r1c8 contains the value 8, some other value must occupy the cell r1c1, which means that the value 7 must occupy the cell r1c8 - a contradiction.
Therefore, the cell r1c8 cannot contain the value 8.
- The move r1c8:=8 has been eliminated.
The cell r1c1 is the only candidate for the value 8 in Row 1.
ctettam9
 
Posts: 8
Joined: 06 November 2005

Postby rubylips » Wed Nov 30, 2005 11:50 am

Chris,

The solver in question is hosted at http://www.act365.com/sudoku. The source code is available under GPL at http://sourceforge.net/projects/sudoku. The most recent release, which is the version that has troubled bennys, doesn't feature Disjoint Subset links, so you won't be able to replicate the analysis presented in this thread. I hope to release an updated version that will over the weekend.
rubylips
 
Posts: 149
Joined: 01 November 2005


Return to Advanced solving techniques