I'll use this puzzle for one more illustration of a new functionality of CSP-Rules, combining two recently added features:
- function
solve-sukaku-grid - output of the final RS (=PM) when a puzzle is not completely solved.
As this is a puzzle from mith, I'm expecting lots of Subsets. So, let's first try to find as many of them as possible, by activating only Subsets in the configuration file:
- Code: Select all
(bind ?*Subsets* TRUE)
(solve ".....9.....95....3.6..2..1..1..6..7...42....58..............7....39....4.7.41..6.")
***********************************************************************************************
*** SudoRules 20.1.s based on CSP-Rules 2.1.s, config = S
*** Using CLIPS 6.32-r773
***********************************************************************************************
234 candidates, 1590 csp-links and 1590 links. Density = 5.83%
hidden-pairs-in-a-block: b4{r5c1 r6c3}{n6 n7} ==> r6c3 ≠ 5, r6c3 ≠ 2, r5c1 ≠ 9, r5c1 ≠ 3
hidden-pairs-in-a-block: b2{r1c4 r2c6}{n1 n6} ==> r2c6 ≠ 8, r2c6 ≠ 7, r2c6 ≠ 4, r1c4 ≠ 8, r1c4 ≠ 7, r1c4 ≠ 3
swordfish-in-columns: n1{c3 c4 c9}{r7 r1 r6} ==> r7c1 ≠ 1, r6c7 ≠ 1, r6c6 ≠ 1, r1c1 ≠ 1
swordfish-in-columns: n9{c2 c5 c8}{r7 r6 r5} ==> r7c9 ≠ 9, r7c1 ≠ 9, r6c9 ≠ 9, r6c7 ≠ 9, r5c7 ≠ 9
swordfish-in-columns: n6{c3 c4 c9}{r6 r7 r1} ==> r7c6 ≠ 6, r7c1 ≠ 6, r6c7 ≠ 6, r1c7 ≠ 6
hidden-pairs-in-a-block: b6{n1 n6}{r5c7 r6c9} ==> r6c9 ≠ 2, r5c7 ≠ 8, r5c7 ≠ 3
hidden-pairs-in-a-block: b7{n1 n6}{r7c3 r8c1} ==> r8c1 ≠ 5, r8c1 ≠ 2, r7c3 ≠ 8, r7c3 ≠ 5, r7c3 ≠ 2
swordfish-in-rows: n7{r2 r5 r8}{c5 c1 c6} ==> r6c6 ≠ 7, r6c5 ≠ 7, r3c6 ≠ 7, r3c1 ≠ 7, r1c5 ≠ 7, r1c1 ≠ 7
hidden-triplets-in-a-column: c1{n1 n6 n7}{r2 r8 r5} ==> r2c1 ≠ 4, r2c1 ≠ 2
hidden-triplets-in-a-row: r1{n1 n6 n7}{c3 c4 c9} ==> r1c9 ≠ 8, r1c9 ≠ 2, r1c3 ≠ 8, r1c3 ≠ 5, r1c3 ≠ 2
naked-pairs-in-a-block: b1{r1c3 r2c1}{n1 n7} ==> r3c3 ≠ 7
hidden-triplets-in-a-column: c6{n1 n6 n7}{r5 r2 r8} ==> r8c6 ≠ 8, r8c6 ≠ 5, r8c6 ≠ 2, r5c6 ≠ 8, r5c6 ≠ 3
naked-triplets-in-a-row: r5{c1 c6 c7}{n6 n7 n1} ==> r5c5 ≠ 7
hidden-pairs-in-a-block: b5{n1 n7}{r5c6 r6c4} ==> r6c4 ≠ 3
swordfish-in-columns: n2{c3 c6 c9}{r4 r9 r7} ==> r9c7 ≠ 2, r9c1 ≠ 2, r7c8 ≠ 2, r7c2 ≠ 2, r7c1 ≠ 2, r4c7 ≠ 2, r4c1 ≠ 2
hidden-single-in-a-column ==> r1c1 = 2
jellyfish-in-columns: n8{c3 c9 c4 c6}{r9 r3 r7 r4} ==> r9c7 ≠ 8, r7c8 ≠ 8, r7c5 ≠ 8, r7c2 ≠ 8, r4c7 ≠ 8, r3c7 ≠ 8
hidden-pairs-in-a-block: b7{n2 n8}{r8c2 r9c3} ==> r9c3 ≠ 5, r8c2 ≠ 5
naked-quads-in-a-row: r7{c1 c2 c8 c5}{n5 n4 n9 n3} ==> r7c6 ≠ 5, r7c6 ≠ 3, r7c4 ≠ 3
x-wing-in-columns: n3{c1 c4}{r3 r4} ==> r4c7 ≠ 3, r4c6 ≠ 3, r3c6 ≠ 3
x-wing-in-columns: n3{c6 c7}{r6 r9} ==> r6c8 ≠ 3, r6c5 ≠ 3, r6c2 ≠ 3
PUZZLE 0 NOT SOLVED. 58 VALUES MISSING.
- Code: Select all
FINAL RESOLUTION STATE:
2 3458 17 16 348 9 458 458 67
17 48 9 5 478 16 2468 248 3
345 6 58 378 2 48 459 1 789
359 1 25 38 6 458 49 7 289
67 39 4 2 389 17 16 389 5
8 259 67 17 459 345 234 249 16
45 459 16 68 35 28 7 359 128
16 28 3 9 578 67 1258 258 4
59 7 28 4 1 2358 359 6 289
We have
our expected lot of Subsets (20, allowing 78 eliminations and a placement), but we can see that they are not enough.
Let's now try to add bivalue-chains, i.e. choose the following settings in the configuration file (to be loaded in another instance of CLIPS):
- Code: Select all
(bind ?*Subsets* TRUE)
(bind ?*Bivalue-Chains* TRUE)
and continue from the previous resolution state:
- Code: Select all
(solve-sukaku-grid
2 3458 17 16 348 9 458 458 67
17 48 9 5 478 16 2468 248 3
345 6 58 378 2 48 459 1 789
359 1 25 38 6 458 49 7 289
67 39 4 2 389 17 16 389 5
8 259 67 17 459 345 234 249 16
45 459 16 68 35 28 7 359 128
16 28 3 9 578 67 1258 258 4
59 7 28 4 1 2358 359 6 289
)
***********************************************************************************************
*** SudoRules 20.1.s based on CSP-Rules 2.1.s, config = BC+S
*** Using CLIPS 6.32-r773
***********************************************************************************************
150 candidates, 537 csp-links and 537 links. Density = 4.81%
biv-chain[3]: r4c4{n3 n8} - b6n8{r4c9 r5c8} - b6n3{r5c8 r6c7} ==> r6c6 ≠ 3
stte
We can see that a single bivalue-chain[3] is enough to finish the puzzle.
[Edit: corrected the printing of Hidden Subsets in blocks]