Hi R. Jamil, for the 3 puzzles you mention when i initialized them with the template procedure i found that they were solved immediately and these are the results i posted
- Code: Select all
........1.......2...3..4..5.....6....7..3.4..21.....8.....1.......25......9...7..
#VT: (6 5 94 92 138 527 89 856 511)
Cells: nil (42) nil nil nil nil nil nil nil
SetVC: ( n2r5c6 n1r2c6 n1r8c3 n1r3c1 n1r9c8 n1r4c7
n2r7c7 n2r4c9 n5r7c8 n5r6c7 n1r5c4 n2r9c2
n2r1c3 n3r6c9 n5r9c1 n5r1c6 n5r4c4 n6r6c3
n7r2c9 n7r4c8 n8r4c5 n4r4c3 n2r3c5 n4r1c8
n5r5c3 n5r2c2 n7r7c3 n7r3c4 n7r1c1 n8r5c1
n8r2c3 n3r8c8 n4r2c1 n7r8c6 n7r6c5 n8r3c7
n8r1c4 n9r4c1 n3r4c2 n9r6c6 n6r8c1 n9r8c7
n4r6c4 n3r7c1 n8r7c6 n3r9c6 n4r7c2 n6r7c9
n8r8c2 n4r8c9 n6r9c4 n4r9c5 n8r9c9 n9r5c9
n9r7c4 n3r2c4 n6r2c7 n9r3c8 n6r5c8 n3r1c7
n9r2c5 n6r3c2 n9r1c2 n6r1c5 )
7 9 2 8 6 5 3 4 1
4 5 8 3 9 1 6 2 7
1 6 3 7 2 4 8 9 5
9 3 4 5 8 6 1 7 2
8 7 5 1 3 2 4 6 9
2 1 6 4 7 9 5 8 3
3 4 7 9 1 8 2 5 6
6 8 1 2 5 7 9 3 4
5 2 9 6 4 3 7 1 8
Solved.
....46...1......8.....3....2.....6.5.5.8...........3...13.........5...7.4.6......
#VT: (144 576 5 128 8 6 104 8 3232)
Cells: nil nil (37) nil nil nil nil nil nil
SetVC: ( n3r5c1 n6r5c5 n6r8c9 n6r7c4 n3r8c6 n4r7c6
n4r8c7 n6r3c8 n6r2c2 n7r7c5 n8r7c7 n1r8c5
n3r4c4 n3r2c9 n3r1c2 n4r6c4 n4r3c9 n4r2c3
n6r6c1 n8r9c5 n9r4c5 n9r6c2 n2r3c2 n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2 4 8
7 5 8 4 2 1 3 6 9
6 1 3 7 8 4 9 5 2
5 9 2 6 1 3 4 8 7
4 8 7 5 9 2 6 3 1
Solved.
i also have the same conception as Ruud about templates and his description of their use as a resolution technique matches my implementation, the only difference being that i don't mix it with other techniques
i obviously agree with the observations he makes:
"There are 46656 different configurations for any value in the grid.
With 1 position given, 5184 configurations are left.
With 2 positions given in 1 chute, 864 configurations are left.
etc."
but i would use different vocabulary to talk about them. Since a sudoku grid can be modeled as a graph it may be convenient to use some concepts from this theory to talk about some of its aspects. The 81 cells of the sudoku are the vertices of the graph and two vertices are adjacent if they are connected by an edge, this notion of adjacency between two sudoku cells is easily defined if the cells are referenced by an RowColBox coordinate system like this:
- Code: Select all
((1 1 1) (1 2 1) (1 3 1) (1 4 2) (1 5 2) (1 6 2) (1 7 3) (1 8 3) (1 9 3)
(2 1 1) (2 2 1) (2 3 1) (2 4 2) (2 5 2) (2 6 2) (2 7 3) (2 8 3) (2 9 3)
(3 1 1) (3 2 1) (3 3 1) (3 4 2) (3 5 2) (3 6 2) (3 7 3) (3 8 3) (3 9 3)
(4 1 4) (4 2 4) (4 3 4) (4 4 5) (4 5 5) (4 6 5) (4 7 6) (4 8 6) (4 9 6)
(5 1 4) (5 2 4) (5 3 4) (5 4 5) (5 5 5) (5 6 5) (5 7 6) (5 8 6) (5 9 6)
(6 1 4) (6 2 4) (6 3 4) (6 4 5) (6 5 5) (6 6 5) (6 7 6) (6 8 6) (6 9 6)
(7 1 7) (7 2 7) (7 3 7) (7 4 8) (7 5 8) (7 6 8) (7 7 9) (7 8 9) (7 9 9)
(8 1 7) (8 2 7) (8 3 7) (8 4 8) (8 5 8) (8 6 8) (8 7 9) (8 8 9) (8 9 9)
(9 1 7) (9 2 7) (9 3 7) (9 4 8) (9 5 8) (9 6 8) (9 7 9) (9 8 9) (9 9 9))
two cells are adjacent or connected if at least one of their RCB coordinates is equal, otherwise they are non-adjacent or disconnected
Two concepts are useful for describing sets of cells:
- Cliques: sets of pairwise connected cells
- independent sets: sets of pairwise disconnected cells
if by abuse of language the 81 cells taken individually are considered as independent sets of size 1 then in a 9×9 Sudoku grid there are:
- Code: Select all
#ind.Sets / size
81 1
2430 2
34506 3
247860 4
901044 5
1586304 6
1259712 7
419904 8
46656 9
for a total of 4,498,497
and templates can be defined as independent sets of size 9 which is the maximum size, all other independent sets as subsets of templates, and here is their distribution:
- Code: Select all
size / (#TP #iS)
1 (5184 81)
2 (864 972) (576 1458)
3 (288 972) (144 11664) (96 17496) (64 4374)
4 (48 34992) (36 11664) (24 69984) (16 131220)
5 (16 26244) (12 139968) (8 209952) (4 524880)
6 (6 46656) (4 419904) (2 839808) (1 279936)
7 (2 419904) (1 839808)
8 (1 419904)
9 (1 46656)
for example:
for independent sets of size 2 there are 972 of them which are subsets of 864 templates and 1458 of 576
for independent sets of size 3 there are 972 of them which are subsets of 288 templates and 11664 of 144, 17496 of 96, 4374 of 64
etc.
and the difference in distribution for each size depends as Ruud observed on the arrangement of the cells on the grid.
a puzzle can be define as a partition of n cells into k independent sets, some partitions give invalid puzzles i.e. zero solutions, others puzzles with one solution and others puzzles with several solutions and a template procedure easily distinguishes between these three categories as Ruud points out.
taking as an example the puzzle given by StrmCkr in the post you quote, here is three partitioning of its 41 cells with the partition (9 6 6 6 6 5 2 1)
- Code: Select all
0.00.000..0.0....0000.00.0.00.0.00.000..000..0.00.....0..0.0.0000..0.0...0....0.0 pattern
6.23.915..3.2....6954.61.3.86.5.43.241..235..5.31.....3..4.2.1514..3.6...2....4.3 0 sol
6.23.915..3.2....6954.16.3.26.5.43.141..235..5.31.....3..4.2.1584..3.6...2....4.3 1 sol StrmCkr
6.23.915..3.2....6954.61.3.28.5.43.141..235..5.36.....3..4.2.1514..3.6...2....4.3 7 sols
Phil explains his method a little
hereregarding this quote from Phil:
"Between them r3c7 and r8c8 include all patterns of 2, so patterns of 7 which include both cells can be deleted. As a result, no pattern of 7 includes r6c9 so 7 can be deleted from r6c9"
if we are to understand that there are only 2 possible templates for 2, i have to disagree with Phil, there are 3 and the one that is part of the solution does not contain r3c7 and therefore doing r3c7=2 would be an error, in fact r3c7=7 is in the solution
- Code: Select all
(3 13 27 28 41 52 60 71 74) (3 13 25 28 41 54 60 71 74) (3 13 25 28 41 53 60 72 74)
• . 2 • . • • • . • . 2 • . • • • . • . 2 • . • • • .
. • . 2 . . . . • . • . 2 . . . . • . • . 2 . . . . •
• • • . • • - • X • • • . • • X • - • • • . • • X • -
2 • . • . • • . • 2 • . • . • • . • 2 • . • . • • . •
• • . . 2 • • . . • • . . 2 • • . . • • . . 2 • • . .
• . • • . . X - - • . • • . . - - X • . • • . . - X -
• . . • . 2 . • • • . . • . 2 . • • • . . • . 2 . • •
• • . . • . • X - • • . . • . • X - • • . . • . • - X
. 2 . . . . • . • . 2 . . . . • . • . 2 . . . . • . •
but as you rightly say if all the possible templates for a value have cells in common these cells can be set to this value, it is the logic of the resolution by templates, an extremely simple logic but which requires, in order not to make mistakes, to be exhaustive in their enumeration.