Pattern Overlay Method

Advanced methods and approaches for solving Sudoku puzzles

Re: Pattern Overlay Method

Postby rjamil » Tue Nov 19, 2024 6:44 pm

Hi P.O.,

Ok. Now I understand how two-digit POM templates are combined, i.e., by taking non-overlapping templates of each digit out of all valid each digit templates.

However, for two-digit (or multi-digit) POM, one need to keep track of all the valid single-digit POM of both (or all of) the digits.

In case of an empty Sudoku puzzle, each digit POM maximum number of valid template count is 15,552 (i.e., 3 x 5184 for each digit). Playing with such a huge data need linked list, which is not available in C language (or, I don't know) right now. Once, I will be able to record such a huge data, i.e., for three-digit, there are 46,656 templates need to be examined.

Thank you for your guidance and support for taking the time to provide such detailed and constructive feedback.

Searched and found Myth Jellies post here, here, here and here.

R. Jamil
rjamil
 
Posts: 785
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Pattern Overlay Method

Postby rjamil » Mon Dec 23, 2024 11:46 am

Hi experts,

While I am studing dynamic memory allocation in C language (as compared to linked lists in C++ language) and thinking about how to implement multi-digit POM, got an idea to implement as follows:

  1. I see no significant difference to capture the valid (possible) templates of each digit, in order to display accordingly. The only thing to compute the elimination(s) / placement(s) is / are to count the valid (possible) templates only, and, any cell that contain particular digit, if absent from / present in all valid (possible) templates, may be eliminated / placed accordingly.
  2. My new idea is to just count for each digit (from 1 ... 9) against each digit except itself, i.e., two unique digits {(1, [2 ... 9]), (2, [1, 3 ... 9]), (3, [1, 2, 4 ... 9]), ...};
    1. If only one occurance found for each digit, then the template is considered as solution;
    2. If more than one occurance found then treat as single-digit POM move;
    3. if no valid (possible) template found then the puzzle has either no or multiple solution;
    4. If step (b) failed then search for 3-digit combinations, then, 4-digit combinations.
The above scenario is searched 9 x 8 = 72 times for 2 unique digit combinations, 9 x 8 x 7 = 504 for 3, and 9 x 8 x 7 x 6 = 3024 for 4, without tracking any template, and give solution.

R. Jamil
rjamil
 
Posts: 785
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Pattern Overlay Method

Postby Hajime » Mon Dec 23, 2024 6:23 pm

Why do you need all the those 46656 patterns.
If you follow the rules of https://www.sudokuwiki.org/Pattern_Overlay for the 3 example here.
You can eliminate all candidates 3's with a "-". And all cells with "ab" have 3 as a solution.
1 extra rule: only houses (row,col,box) that are touched are included. Others are out-of-reach.
So in the next example all 4's are candidates
Code: Select all
...4.4...
.........
.........
4.......4
.........
4.......4
.........
.........
...4.4...
You can pick the 4's in row 1, but they influence only row 9.
Row 4 and 6 are untouched, so you can not eliminate the 4's there, not even if the have the mark "-".
Rigth?
Last edited by Hajime on Tue Dec 24, 2024 7:18 am, edited 1 time in total.
User avatar
Hajime
 
Posts: 1386
Joined: 20 April 2018
Location: Fryslân

Re: Pattern Overlay Method

Postby P.O. » Mon Dec 23, 2024 6:26 pm

hi R. Jamil
there are certainly several ways to use templates as a resolution technique, personally i use the following method:

with the combinations of 2, to be kept
a template for 1 must figure in all these combinations: (1 2) (1 3) (1 4) (1 5) (1 6) (1 7) (1 8) (1 9)
a template for 2 must figure in all these combinations: (1 2) (2 3) (2 4) (2 5) (2 6) (2 7) (2 8) (2 9)
a template for 3 must figure in all these combinations: (1 3) (2 3) (3 4) (3 5) (3 6) (3 7) (3 8) (3 9)
a template for 4 must figure in all these combinations: (1 4) (2 4) (3 4) (4 5) (4 6) (4 7) (4 8) (4 9)
a template for 5 must figure in all these combinations: (1 5) (2 5) (3 5) (4 5) (5 6) (5 7) (5 8) (5 9)
a template for 6 must figure in all these combinations: (1 6) (2 6) (3 6) (4 6) (5 6) (6 7) (6 8) (6 9)
a template for 7 must figure in all these combinations: (1 7) (2 7) (3 7) (4 7) (5 7) (6 7) (7 8) (7 9)
a template for 8 must figure in all these combinations: (1 8) (2 8) (3 8) (4 8) (5 8) (6 8) (7 8) (8 9)
a template for 9 must figure in all these combinations: (1 9) (2 9) (3 9) (4 9) (5 9) (6 9) (7 9) (8 9)

with the combinations of 3, to be kept
a template for 1 must figure in all these combinations:
(1 2 3) (1 2 4) (1 2 5) (1 2 6) (1 2 7) (1 2 8) (1 2 9) (1 3 4) (1 3 5)
(1 3 6) (1 3 7) (1 3 8) (1 3 9) (1 4 5) (1 4 6) (1 4 7) (1 4 8) (1 4 9)
(1 5 6) (1 5 7) (1 5 8) (1 5 9) (1 6 7) (1 6 8) (1 6 9) (1 7 8) (1 7 9)
(1 8 9)
a template for 2 must figure in all these combinations:
(1 2 3) (1 2 4) (1 2 5) (1 2 6) (1 2 7) (1 2 8) (1 2 9) (2 3 4) (2 3 5)
(2 3 6) (2 3 7) (2 3 8) (2 3 9) (2 4 5) (2 4 6) (2 4 7) (2 4 8) (2 4 9)
(2 5 6) (2 5 7) (2 5 8) (2 5 9) (2 6 7) (2 6 8) (2 6 9) (2 7 8) (2 7 9)
(2 8 9)
a template for 3 must figure in all these combinations:
(1 2 3) (1 3 4) (1 3 5) (1 3 6) (1 3 7) (1 3 8) (1 3 9) (2 3 4) (2 3 5)
(2 3 6) (2 3 7) (2 3 8) (2 3 9) (3 4 5) (3 4 6) (3 4 7) (3 4 8) (3 4 9)
(3 5 6) (3 5 7) (3 5 8) (3 5 9) (3 6 7) (3 6 8) (3 6 9) (3 7 8) (3 7 9)
(3 8 9)
etc.

with the combinations of 4, to be kept
a template for 1 must figure in all these combinations:
(1 2 3 4) (1 2 3 5) (1 2 3 6) (1 2 3 7) (1 2 3 8) (1 2 3 9) (1 2 4 5)
(1 2 4 6) (1 2 4 7) (1 2 4 8) (1 2 4 9) (1 2 5 6) (1 2 5 7) (1 2 5 8)
(1 2 5 9) (1 2 6 7) (1 2 6 8) (1 2 6 9) (1 2 7 8) (1 2 7 9) (1 2 8 9)
(1 3 4 5) (1 3 4 6) (1 3 4 7) (1 3 4 8) (1 3 4 9) (1 3 5 6) (1 3 5 7)
(1 3 5 8) (1 3 5 9) (1 3 6 7) (1 3 6 8) (1 3 6 9) (1 3 7 8) (1 3 7 9)
(1 3 8 9) (1 4 5 6) (1 4 5 7) (1 4 5 8) (1 4 5 9) (1 4 6 7) (1 4 6 8)
(1 4 6 9) (1 4 7 8) (1 4 7 9) (1 4 8 9) (1 5 6 7) (1 5 6 8) (1 5 6 9)
(1 5 7 8) (1 5 7 9) (1 5 8 9) (1 6 7 8) (1 6 7 9) (1 6 8 9) (1 7 8 9)
a template for 2 must figure in all these combinations:
(1 2 3 4) (1 2 3 5) (1 2 3 6) (1 2 3 7) (1 2 3 8) (1 2 3 9) (1 2 4 5)
(1 2 4 6) (1 2 4 7) (1 2 4 8) (1 2 4 9) (1 2 5 6) (1 2 5 7) (1 2 5 8)
(1 2 5 9) (1 2 6 7) (1 2 6 8) (1 2 6 9) (1 2 7 8) (1 2 7 9) (1 2 8 9)
(2 3 4 5) (2 3 4 6) (2 3 4 7) (2 3 4 8) (2 3 4 9) (2 3 5 6) (2 3 5 7)
(2 3 5 8) (2 3 5 9) (2 3 6 7) (2 3 6 8) (2 3 6 9) (2 3 7 8) (2 3 7 9)
(2 3 8 9) (2 4 5 6) (2 4 5 7) (2 4 5 8) (2 4 5 9) (2 4 6 7) (2 4 6 8)
(2 4 6 9) (2 4 7 8) (2 4 7 9) (2 4 8 9) (2 5 6 7) (2 5 6 8) (2 5 6 9)
(2 5 7 8) (2 5 7 9) (2 5 8 9) (2 6 7 8) (2 6 7 9) (2 6 8 9) (2 7 8 9)
etc.

etc.

with this method if the puzzle has multiple solutions all its solutions are obtained
if the puzzle has no solution this is noted when there is no more template for certain combinations
for example this puzzle is invalid, with my implementation it passes the combinations of 2 then is found invalid with the combinations of 3
Code: Select all
.  6  .  2  .  .  .  .  .
.  .  3  .  9  .  .  .  .
.  4  .  6  .  1  .  .  .
1  .  .  .  5  .  2  .  .
4  .  7  .  3  .  .  1  .
2  .  .  .  4  .  .  .  5
.  1  8  7  .  .  .  3  .
.  .  .  .  1  .  8  .  .
.  .  .  .  .  9  .  .  .

.6.2.......3.9.....4.6.1...1...5.2..4.7.3..1.2...4...5.187...3.....1.8.......9...

5789    6       1       2       78      3       4579    45789   4789             
578     278     3       458     9       4578    14567   245678  124678           
5789    4       259     6       78      1       3579    25789   23789           
1       389     69      89      5       678     2       46789   346789           
4       5       7       89      3       2       69      1       689             
2       389     69      1       4       678     3679    6789    5               
569     1       8       7       26      456     4569    3       2469             
35679   2379    24569   345     1       456     8       245679  24679           
3567    237     2456    3458    268     9       14567   24567   12467           
196 candidates.
PM VALID.

#VT: (2 10 4 15 23 24 78 20 48)
Cells: nil nil nil nil nil nil nil nil nil
Candidates: nil nil (65 74) (16 17 18) (10 16 17) (35 36 52 53 60 66 69 75) (15) (11 18) nil
                                                                                 
5789    6       1       2       78      3       4579    45789   4789             
78      27      3       458     9       458     167     2678    1267             
5789    4       259     6       78      1       3579    25789   23789           
1       389     69      89      5       678     2       4789    34789           
4       5       7       89      3       2       69      1       689             
2       389     69      1       4       678     379     789     5               
569     1       8       7       26      45      4569    3       2469             
35679   279     2459    345     1       45      8       245679  24679           
3567    27      245     3458    268     9       14567   24567   12467           
177 candidates.
PM VALID.

 2combs
#VT: (2 10 4 15 23 20 78 19 46)
Cells: nil nil nil nil nil nil nil nil nil
Candidates: nil nil nil nil nil (61) nil nil nil

5789    6       1       2       78      3       4579    45789   4789             
78      27      3       458     9       458     167     2678    1267             
5789    4       259     6       78      1       3579    25789   23789           
1       389     69      89      5       678     2       4789    34789           
4       5       7       89      3       2       69      1       689             
2       389     69      1       4       678     379     789     5               
569     1       8       7       26      45      459     3       2469             
35679   279     2459    345     1       45      8       245679  24679           
3567    27      245     3458    268     9       14567   24567   12467           
176 candidates.
PM VALID.

 3combs
Puzzle invalid: .6.2.......3.9.....4.6.1...1...5.2..4.7.3..1.2...4...5.187...3.....1.8.......9...
#VT: (2 9 4 12 14 8 76 0 13)
P.O.
 
Posts: 1764
Joined: 07 June 2021

Re: Pattern Overlay Method

Postby rjamil » Wed Dec 25, 2024 2:04 am

Hi P.O.,

Thanks for providing the expanded version of what I was thinking.

Now, I am rethinking about how to code the multi-digit POM search routine as per pjb described here and here.

R. Jamil
rjamil
 
Posts: 785
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Pattern Overlay Method

Postby P.O. » Wed Dec 25, 2024 12:40 pm

once what needs to be done has been specified enough to consider a technical implementation, all that remains is to set up the data structures and algorithms and there is also more than one way to proceed, in the link you cite pjb outlined his method, i did the same here and Dobrichev here also posting his code which is in C the language you use

he uses a puzzle to illustrate his method, step B of which corresponds to the computation of the templates for each value at the beginning of the procedure, i quote:
"Step B. Apply the 9 masks over all 46656 templates. Store all disjoint to the mask templates as candidates for the respective digit.
Template distribution 36 28 54 28 14 4 6 14 42 product=301112598528 sum=226"

solving the puzzle i get the same distribution, note that the puzzle is in 2-template and can be solved by considering only the combination (6 7)
Dobrichev's example:
Code: Select all
.  .  .  .  .  1  .  .  2
.  .  3  .  4  .  .  5  .
.  6  .  7  .  .  8  .  .
.  .  6  .  .  .  .  7  .
.  4  .  .  2  .  .  .  3
1  .  .  .  .  4  9  .  .
.  .  8  .  .  9  5  .  .
.  7  .  8  .  .  .  6  .
6  .  .  .  5  .  .  .  .

.....1..2..3.4..5..6.7..8....6....7..4..2...31....49....8..95...7.8...6.6...5....

45789   589     4579    3569    3689    1       3467    349     2               
2789    1289    3       269     4       268     167     5       1679             
2459    6       12459   7       39      235     8       1349    149             
23589   23589   6       1359    1389    358     124     7       1458             
5789    4       579     1569    2       5678    16      18      3               
1       2358    257     356     3678    4       9       28      568             
234     123     8       12346   1367    9       5       1234    147             
23459   7       12459   8       13      23      1234    6       149             
6       1239    1249    1234    5       237     12347   123489  14789           
209 candidates.

#VT: (36 28 54 28 14 4 6 14 42)
Cells: nil nil nil nil nil (54) nil nil nil
SetVC: ( n6r6c9   n1r5c7   n8r5c8   n2r6c8   n4r4c7   n5r4c9
         n8r9c9 )

#VT: (10 14 54 12 7 4 6 4 42)
Cells: nil nil nil nil nil nil nil nil nil
Candidates:nil nil nil nil nil nil nil (11) nil

45789  589    4579   3569   3689   1      367    349    2               
2789   129    3      269    4      268    67     5      179             
2459   6      12459  7      39     235    8      1349   149             
2389   2389   6      139    1389   38     4      7      5               
579    4      579    569    2      567    1      8      3               
1      358    57     35     378    4      9      2      6               
234    123    8      12346  1367   9      5      134    147             
23459  7      12459  8      13     23     23     6      149             
6      1239   1249   1234   5      237    237    1349   8               
166 candidates.

 2combs
#VT: (10 14 46 12 7 4 3 3 26)
Cells: nil nil nil nil nil nil (50 63 78) nil nil
SetVC: ( n7r6c5   n7r7c9   n7r9c6   n5r6c3   n3r6c4   n8r4c6
         n8r6c2   n5r8c1   n5r1c2   n8r1c5   n8r2c1   n5r5c4
         n5r3c6   n6r7c5   n6r5c6   n7r2c7   n2r2c6   n3r8c6
         n2r8c7   n3r9c7   n6r1c7   n1r8c5   n9r1c4   n6r2c4
         n3r3c5   n1r4c4   n9r4c5   n3r1c8 )

#VT: (3 4 2 12 1 1 2 1 2)
Cells: nil nil nil nil nil nil nil nil (11 37)
SetVC: ( n9r2c2   n1r2c9   n9r5c1   n7r5c3   n4r1c3   n2r3c1
         n1r3c3   n3r4c1   n2r4c2   n4r7c1   n2r7c4   n1r7c8
         n9r8c3   n4r8c9   n1r9c2   n2r9c3   n4r9c4   n9r9c8
         n7r1c1   n4r3c8   n9r3c9   n3r7c2 )
7 5 4   9 8 1   6 3 2
8 9 3   6 4 2   7 5 1
2 6 1   7 3 5   8 4 9
3 2 6   1 9 8   4 7 5
9 4 7   5 2 6   1 8 3
1 8 5   3 7 4   9 2 6
4 3 8   2 6 9   5 1 7
5 7 9   8 1 3   2 6 4
6 1 2   4 5 7   3 9 8

puzzle in 2(1)-Template
P.O.
 
Posts: 1764
Joined: 07 June 2021

Re: Pattern Overlay Method

Postby rjamil » Wed Dec 25, 2024 4:45 pm

Hi P.O.,

Many thanks for such a detailed and informative analysis with patience.

Actually, what I am thinking is to avoid storing the valid (possible) templates (either in linked list or dynamic memory allocation). All I see is that, the count of single-digit and multi-digit templates are sufficient. I am now thinking to implement the multi-digit POM without keep tracking the templates (just like I did for single-digit POM) as follows:

  1. for each template of digit 1;
  2. if digit 1 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 1;
  3. for each template of digit 2;
  4. if digit 2 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 3;
  5. for each template of digit 3;
  6. if digit 3 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 5;
  7. for each template of digit 4;
  8. if digit 4 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 7;
  9. for each template of digit 5;
  10. if digit 5 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 9;
  11. for each template of digit 6;
  12. if digit 6 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 11;
  13. for each template of digit 7;
  14. if digit 7 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 13;
  15. for each template of digit 8;
  16. if digit 8 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 15;
  17. for each template of digit 9;
  18. if digit 9 is absent in template's nine disjoint cells as clue or solved or candidate then go to step 17;
  19. all nine digits template are considered as solution;
  20. count number of solution;
  21. next template of digit 9;
  22. next template of digit 8;
  23. next template of digit 7;
  24. next template of digit 6;
  25. next template of digit 5;
  26. next template of digit 4;
  27. next template of digit 3;
  28. next template of digit 2;
  29. next template of digit 1;
  30. if (number of solution) is one than puzzle is solved else puzzle has (number of solution) solution(s).
The above flow chart reflects what I understand from pjb implemented in his solver as described here.

R. Jamil

Note: I checked nine loops for generating the 46,656 templates as follows:
Hidden Text: Show
Code: Select all
#include <stdio.h>

int main (void)
{
       int w[81]     = {     // Band, Stack, Row, Box and Column for 81 Cell positions
      262657,    262658,    262660, 134480904, 134480912, 134480928, 268699712, 268699776, 268699904,
      524801,    524802,    524804, 134743048, 134743056, 134743072, 268961856, 268961920, 268962048,
     1049089,   1049090,   1049092, 135267336, 135267344, 135267360, 269486144, 269486208, 269486336,
   538972161, 538972162, 538972164, 673193992, 673194000, 673194016, 807419968, 807420032, 807420160,
   541069313, 541069314, 541069316, 675291144, 675291152, 675291168, 809517120, 809517184, 809517312,
   545263617, 545263618, 545263620, 679485448, 679485456, 679485472, 813711424, 813711488, 813711616,
  1090551809,1090551810,1090551812,1224802312,1224802320,1224802336,1359085632,1359085696,1359085824,
  1107329025,1107329026,1107329028,1241579528,1241579536,1241579552,1375862848,1375862912,1375863040,
  1140883457,1140883458,1140883460,1275133960,1275133968,1275133984,1409417280,1409417344,1409417472},
           B[513] = {        // Count bitwise Cell values
   0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   5, 6, 6, 7, 6, 7, 7, 8, 6, 7, 7, 8, 7, 8, 8, 9,10};

  for (int x = 0, a = 0; a < 9; ++a)
    for (int b = 9; b < 18; ++b)
    {
      if (B[(w[a] | w[b]) & 511] < 2 ||
        B[((w[a] | w[b]) >> 9) & 511] < 2)
        continue;
      for (int c = 18; c < 27; ++c)
      {
        if (B[(w[a] | w[b] | w[c]) & 511] < 3 ||
          B[((w[a] | w[b] | w[c]) >> 9) & 511] < 3)
          continue;
        for (int d = 27; d < 36; ++d)
        {
          if (B[(w[a] | w[b] | w[c] | w[d]) & 511] < 4 ||
            B[((w[a] | w[b] | w[c] | w[d]) >> 9) & 511] < 4)
            continue;
          for (int e = 36; e < 45; ++e)
          {
            if (B[(w[a] | w[b] | w[c] | w[d] | w[e]) & 511] < 5 ||
              B[((w[a] | w[b] | w[c] | w[d] | w[e]) >> 9) & 511] < 5)
              continue;
            for (int f = 45; f < 54; ++f)
            {
              if (B[(w[a] | w[b] | w[c] | w[d] | w[e] | w[f]) & 511] < 6 ||
                B[((w[a] | w[b] | w[c] | w[d] | w[e] | w[f]) >> 9) & 511] < 6)
                continue;
              for (int g = 54; g < 63; ++g)
              {
                if (B[(w[a] | w[b] | w[c] | w[d] | w[e] | w[f] | w[g]) & 511] < 7 ||
                  B[((w[a] | w[b] | w[c] | w[d] | w[e] | w[f] | w[g]) >> 9) & 511] < 7)
                  continue;
                for (int h = 63; h < 72; ++h)
                {
                  if (B[(w[a] | w[b] | w[c] | w[d] | w[e] | w[f] | w[g] | w[h]) & 511] < 8 ||
                    B[((w[a] | w[b] | w[c] | w[d] | w[e] | w[f] | w[g] | w[h]) >> 9) & 511] < 8)
                    continue;
                  for (int i = 72; i < 81; ++i)
                  {
                    if (B[(w[a] | w[b] | w[c] | w[d] | w[e] | w[f] | w[g] | w[h] | w[i]) & 511] < 9 ||
                      B[((w[a] | w[b] | w[c] | w[d] | w[e] | w[f] | w[g] | w[h] | w[i]) >> 9) & 511] < 9)
                      continue;
                    printf ("%d {%d,%d,%d,%d,%d,%d,%d,%d,%d},\n", ++x, a, b, c, d, e, f, g, h, i);
                  }
                }
              }
            }
          }
        }
      }
    }
}
rjamil
 
Posts: 785
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Pattern Overlay Method

Postby P.O. » Thu Dec 26, 2024 9:20 am

in your procedure you write: for each template of digit 1, for each template of digit 2 etc. doesn't that indicate that you have all the templates for each value available?

in the second link you give pjb explicitly write:
"Generate all patterns for each number in separate arrays and order them by increasing size."

it is difficult to reconcile this with:
"(...) to avoid storing the valid (possible) templates (...) without keep tracking the templates (...)"

i have a procedure similar to the one you describe, a DFS backtracking algorithm, i use it to count the number of solutions and possibly to recover them but i need to have all the templates for each value

it should also be noted that such a procedure strictly speaking does not provide a resolution path for the puzzle; it does not make the grid evolve progressively towards its solution, allowing a classification of the puzzles into the maximum size of combinations sufficient to solve them and also does not allow us to know which combinations actually solve the puzzles.
P.O.
 
Posts: 1764
Joined: 07 June 2021

Re: Pattern Overlay Method

Postby rjamil » Thu Dec 26, 2024 3:19 pm

Hi P.O.,

Many thanks for your experience based advice and wise counselling.

Well, I'll use static two-dimensional array containing 46,656 x 9 templates. (The 15,552 x 8, 9 x 60 and 8, i.e., less than one-third of actual POM templates are only for fun and used for single-digit POM when first row's cell is already known.)
I have programmed robust search method to find a specific digit's template on the fly without need to store it anywhere.
I see no need to get each digit's template out of all first; and, then manipulate them separately.

R. Jamil
rjamil
 
Posts: 785
Joined: 15 October 2014
Location: Karachi, Pakistan

Previous

Return to Advanced solving techniques