Strong Links & Weaklinks

Programs which generate, solve, and analyze Sudoku puzzles

Strong Links & Weaklinks

Postby StrmCkr » Tue Apr 24, 2018 3:15 am

    Strong link
    0). Bivalves cells {internal relation }
    Code: Select all
    .  .  . | . AB . | . . .

    1).2 bi locals in a row/Col/Box
    Code: Select all
    /  x  / | /  /  / | /  x  /

    2). 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a box
    Code: Select all
    /  x  / |  /  /  /  |  x  x  x

    3). 2-3 cell in Row/Col in a box with 1 cells in a same row/col in a box
    Code: Select all
    x  x  x  |  /  /  /  |  /  x  /

    4). 2-3 cells in a row/col in a box with 2-3 cells in same row/col in a diffrent box
    Code: Select all
    x  x  x  |  /  /  /  |  x  x  x

    5). Empty rectangle intersection {E.R.I} the sum of all digits in a box are found on 1 col and 1 row see Note at bottom of section
    Code: Select all
    / x /
    x * x
    / x /

    Note:ERI's are an exception to a valid chain starting spot it can be used only if the center cell is absent as this leaves either the row or col true, the * cell is used as a pivot between row/col
    Weakly Linked called a Weak inference
    exists in cells that are part of a strong link set, that see parts of another strong link sets without being part of it, or directly seeing all of it.
    0,0). Bivalve that sees another bivalve with digit shared
    Code: Select all
    .  .  . | . AB . | . . .
    .  .  . | . BC . | . . .

    0,1). Bivalve that sees 1 digit of bi-local digit
    Code: Select all
    .  AB  . | .  .  . | .  .  .
    /  x   / | /  /  / | /  x  /

    0,2). Bivalve that sees the 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    .  AB  . | .  .  . | .  .  .
    /  x   / | /  /  / | x  x  x

    0,3). Bivalve that sees the 2-3 cells in Row/Col in a box with 1 cells in a same row/col in a different box
    Code: Select all
    .  AB  . | .  .  . | .  .  .
    x  x   x | /  /  / | /  x  /

    0,4). Bivalve that sees the 2-3 cells in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    .  AB  . | .  .  . | .  .  .
    x  x   x | /  /  / | x  x  x

    0,5). Bivalve that sees an ERI's * cell
    Code: Select all
    .  AB  . | .  .  . | .  .  .
    ----------------------------
    /  x   / |
    x  *   x |
    /  x   / |

    1,0) a bi-local digit that 1 cell sees a bivalve
    Code: Select all
    /  x   / | /  /  / | /  x  /
    .  AB  . | .  .  . | .  .  .

    1,1) a bi-local digit that 1 of the cells sees a bi-local digit
    Code: Select all
    /  x   / | /  /  / | /  x  /
    /  x   / | /  /  / | /  x  /

    1,2) a bi-local digit that 1 of the cells sees the 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    /  x   / | /  /  / | /  x  /
    /  x   / | /  /  / | x  x  x

    1,3) a bi-local digit that 1 of the cells sees the 2-3 cells in Row/Col in a box with 1 cells in a same row/col in a different box
    Code: Select all
    /  x   / | /  /  / | /  x  /
    x  x   x | /  /  / | /  x  /

    1,4) a bi-local digit that 1 of the cells sees all the 2-3 cells in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    /  x   / | /  /  / | /  x  /
    x  x   x | /  /  / | x  x  x

    1,5) a bi-local digit that 1 of the cells sees the * cell of an ERI
    Code: Select all
    /  x   / | /  /  / | /  x  /
    ----------------------------
    /  x   / |
    x  *   x |
    /  x   / |

    2,0). 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box, where the 1 cell sees the bivalve
    Code: Select all
    /  x   / | /  /  / | x  x  x
    .  AB  . | .  .  . | .  .  .

    2,1). 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box, where the 1 cell sees 1 cell of a bi local digit.
    Code: Select all
    /  x   / | /  /  / | x  x  x
    /  x   / | /  /  / | /  x  /

    2,2). 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box, where the 1 cell sees the "1" cell in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    /  x   / | /  /  / | x  x  x
    /  x   / | /  /  / | x  x  x

    2,3). 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box, where the 1 cell sees the "2-3" cell in Row/Col in a box with 1 cells in a same row/col in a different box
    Code: Select all
    /  x   / | /  /  / | x  x  x
    x  x   x | /  /  / | /  x  /

    2,4). 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box, where the 1 cell sees the "2-3" cell in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    /  x   / | /  /  / | x  x  x
    x  x   x | /  /  / | x  x  x

    2,5). 1 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box, where the 1 cell sees the * cell of an eri
    Code: Select all
    /  x   / | /  /  / | x  x  x
    ----------------------------
    /  x  /  |
    x  *  x  |
    /  x  /  |

    3,0). the 2-3 cells in Row/Col in a box with 1 cells in a same row/col in a different box where the Bivalve that sees 2-3 cell.
    Code: Select all
     
    x  x   x | /  /  / | /  x  /
    .  AB  . | .  .  . | .  .  .

    3,1) the 2-3 cells in Row/Col in a box with 1 cells in a same row/col in a different box where the bi-local digit that 1 of the cells sees 2-3 cells
    Code: Select all
    x  x   x | /  /  / | /  x  /
    /  x   / | /  /  / | /  x  /

    3,2). 3-2 cell in Row/Col in a box with 1 cell in a same row/col in a different box, where the 2-3 cell sees the "1" cell in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    x  x   x | /  /  / | /  x  /
    /  x   / | /  /  / | x  x  x

    3,3). 3-2 cell in Row/Col in a box with 1 cell in a same row/col in a different box, where the 2-3 cell sees the "2-3" cells in Row/Col in a box with 1 cell in a same row/col in a different box
    Code: Select all
    x  x   x | /  /  / | /  x  /
    x  x   x | /  /  / | /  x  /

    3,4). 3-2 cell in Row/Col in a box with 1 cell in a same row/col in a different box, where the 2-3 cell sees the "2-3" cells in Row/Col in a box with 2-3 cell in a same row/col in a different box
    Code: Select all
    x  x   x | /  /  / | /  x  /
    x  x   x | /  /  / | x  x  x

    3,5).
    Code: Select all
     NO valid formation

    4,0). the 2-3 cells in Row/Col in a box with 2-3 cells in a same row/col in a different box where the 2-3 cell sees the Bivalve
    Code: Select all
    x  x   x | /  /  / | x  x  x
    .  AB  . | .  .  . | .  .  .

    4,1) 2-3 cells in Row/Col in a box with 2-3 cells in a same row/col in a different box where a bi-local digit sees all of one boxes digits.
    Code: Select all
    x  x   x | /  /  / | x  x  x
    /  x   / | /  /  / | /  x  /

    4,2). 2-3 cell in Row/Col in a box with 2-3 cells in a same row/col in a different box, where the (2-3) cell sees the "1" cell in Row/Col in a box with 2-3 cells in a same row/col in a different box
    Code: Select all
    x  x   x | /  /  / | x  x  x
    /  x   / | /  /  / | x  x  x

    4,3). 3-2 cell in Row/Col in a box with 2-3 cell in a same row/col in a different box, where the 2-3 cell sees the "2-3" cells in Row/Col in a box with 1 cell in a same row/col in a different box
    Code: Select all
    x  x   x | /  /  / | x  x  x
    x  x   x | /  /  / | /  x  /

    4,4). 3-2 cell in Row/Col in a box with 2-3 cell in a same row/col in a different box, where the 2-3 cell sees the "2-3" cells in Row/Col in a box with 2-3 cell in a same row/col in a different box
    Code: Select all
    x  x   x | /  /  / | x  x  x
    x  x   x | /  /  / | x  x  x

    4,5).
    Code: Select all
    no valid formation

    5,0). an ERI's * cell sees the Bivalve
    Code: Select all
    /  x   / |
    x  *   x |
    /  x   / |
    ----------------------------
    .  AB  . | .  .  . | .  .  .

    5,1) the * cell of an ERI sees the 1 of the bi-local digit
    Code: Select all
    /  x   / |
    x  *   x |
    /  x   / |
    ----------------------------
    /  x   / | /  /  / | /  x  /

    5,2). the * cell of an eri see the "1" digit in a row/col of a box with 2-3 cells in same row/col of a different box.
    Code: Select all
    /  x  /  |
    x  *  x  |
    /  x  /  |
    ----------------------------
    /  x   / | /  /  / | x  x  x

    5,3).
    Code: Select all
     NO valid formation

    5,4).
    Code: Select all
    no valid formation


    5,5). the * cell an ERI sees the * sell of a 2nd ERI
    Code: Select all
    /  x  /  |
    x  *  x  |
    /  x  /  |
    ----------------------------
    /  x  /  |
    x  *  x  |
    /  x  /  |

.......work in progress........
Last edited by StrmCkr on Fri Jan 13, 2023 5:35 am, edited 1 time in total.
Some do, some teach, the rest look it up.
stormdoku
User avatar
StrmCkr
 
Posts: 1430
Joined: 05 September 2006

Re: Strong Links & Weaklinks

Postby StrmCkr » Tue Apr 24, 2018 6:26 am

what to do with all that data:

data save: Show
Code: Select all
{link type data base}
Linkset : stronglk; // array [ 0..9][0..5][0..9] of numberset[0..80]//setwise
{digit selected[1..9]}
{0: bivavel,
1:  2 cells in a sector
2: cell in sector , grouped link to another = all digits in that sector
3: cells in sector, as a grouped link to a single cell = all digits in that sector
4: cells in sector, as a grouped link to a grouped node = all digits in that sector
5: ERI}
{ internal data as:
 0 starting digit,
 1 active cell,
 2  linked cells,
 3 next link digit,
 4  sector its in,
 5 peers sector the link cells are is in.
 6  previous - digit swap is applicable 0 = off
 7 digit swap is applicable 0 = off
 8 potential elimination cells for basic ...end cell
 9 potential elimination for ring codes  ...start cell
 }


strong link builder: Show
Code: Select all
Procedure links;{rebuild}
var
N,xn,q,j,a,b,c,d,e,m,n2:integer;
 output: text;
 used:numberset;
begin
setlength(Linkset,10,6,0);

for n:= 1 to 9 do
begin
q:=-1;
A:=-1;
b:=-1;
c:=-1;
D:=-1;
e:=-1;
used:=[];
 for xn:= 0 to 26 do
   begin

    {bivavle cell}
    if DigitRCB[xn,n] <> []
     then
      begin
             for J in (DigitRCB[xn,n]-used) do
        if nm[j] = 2
          then
              begin
              include(used,j);
           inc(q);         
           setlength(linkset[n][0],q+1);
         
           include(linkset[n][0][q,0],n);
           include(linkset[n][0][q,1],j);

              linkset[n][0][q,2]:=[j];
             
           for m in (pm[j]-[n]) do
            begin
              include(linkset[n][0][q,3],m);         
            linkset[n][0][q,9]:= peer[j] * digitcell[m];
            end;             

              linkset[n][0][q,4]:=cellsec[j];
              linkset[n][0][q,5]:=CellSec[j];         
         
              linkset[n][0][q,6]:=[n];
           linkset[n][0][q,7]:=[m];
              linkset[n][0][q,8]:= peer[j] * digitcell[n] ;   
               
           end;
        end;{bivavle}
     
      {bi local}       
      if (sec[xn,n] = 2 )
          then         
          for J in DigitRCB[xn,n] do
            begin
           
            inc(a);
           
             setlength(linkset[n][1],a+1);
            include(linkset[n][1][a,0],n);
             include(linkset[n][1][a,1],j);
            linkset[n][1][a,2]:= Digitrcb[xn,n] - [j];
            include(linkset[n][1][a,3],n);
            //include(linkset[n,1,a,4],xn);
             linkset[n][1][a,4]:=cellsec[j] - [xn];
           
            for m in digitRCB[xn,n] -[j] do
             linkset[n][1][a,5]:=cellsec[m]-[xn];           
                 
              linkset[n][1][a,6]:=pm[j]-[n];
             linkset[n][1][a,7]:=pm[m]-[n];
             linkset[n][1][a,8]:=peer[j]*digitcell[n] -[m];                 
             linkset[n][1][a,9]:=peer[m]*digitcell[n] -[j];
           
                end; {bilocal}
           
      { single + grouped & Grouped + single}       
      if (sec[xn,n] <5) and (Sec[xn,n] >2)
          then
            for J in DigitRCB[xn,n] do
              for m in peerRCB[xn] do
                 if  ((DigitRCB[m,n] * DigitRCB[xn,n])  + [j] = DigitRCB[xn,n] )
                     and not ( J in DigitRCB[m,n])   
                      then               
                   begin
            { single + grouped}       
                  inc(b);
            setlength(linkset[n][2],b+1);
            include(linkset[n][2,b,0],n);
             include(linkset[n][2,b,1],j);
            linkset[n][2,b,2]:= Digitrcb[xn,n] - [j];
            include(linkset[n][2,b,3],n);
            linkset[n][2,b,4]:=cellsec[j] - [xn];
            include(linkset[n][2,b,5],m);           
             linkset[n][2,b,6]:=pm[j]-[n];
             linkset[n][2,b,7]:=[0];
             linkset[n][2,b,9]:= Digitrcb[m,n]- (DigitRCB[m,n] * DigitRCB[xn,n]) ;
             linkset[n][2,b,8]:= peer[j]* digitcell[n]-(DigitRCB[m,n] * DigitRCB[xn,n]);
           
                 { grouped + single}
                  inc(c);
            setlength(linkset[n][3],c+1);
            include(linkset[n][3,c,0],n);
            linkset[n][3,c,1]:= Digitrcb[xn,n] - [j];
             include(linkset[n][3,c,2],j);           
            include(linkset[n][3,c,3],n);
            include(linkset[n][3,c,4],m);
            linkset[n][3,c,5]:= cellsec[j] - [xn] ;             
            linkset[n][3,c,6]:=[0];
            linkset[n][3,c,7]:=pm[j]-[n];
            linkset[n][3,c,9]:= peer[j] * digitcell[n]-(DigitRCB[m,n] * DigitRCB[xn,n]);
            linkset[n][3,c,8]:= DigitRCB[m,n]  -(DigitRCB[m,n] * DigitRCB[xn,n]) ;
                  end;
                 
   {Grouped + grouped}       
if (sec[xn,n] <7) and (Sec[xn,n] >4)
    then
       for J in peerrcb[xn] do
        for m in (peerrcb[xn]-[0..j]) do
        if ((DigitRCB[j,n] * DigitRCB[xn,n]) + (DigitRCB[m,n] * DigitRCB[xn,n]) = (DigitRCB[xn,n]))
           and (DigitRCB[j,n] * DigitRCB[m,n] = [] )
            then
              begin
         
               inc(d);
            setlength(linkset[n][4],d+1);
            include(linkset[n][4,d,0],n);
            linkset[n][4,d,1]:=(DigitRCB[xn,n] * Digitrcb[j,n]);
            linkset[n][4,d,2]:=(DigitRCB[xn,n] * DigitRCB[m,n]);
            include(linkset[n][4,d,3],n);
            include(linkset[n][4,d,4],J);
            include(linkset[n][4,d,5],m);           
               linkset[n][4,d,6]:=[0];   
            linkset[n][4,d,7]:=[0];
            linkset[n][4,d,9]:= DigitRCB[m,n] - (DigitRCB[xn,n] * DigitRCB[m,n]);
            linkset[n][4,d,8]:= DigitRCB[j,n] - (DigitRCB[xn,n] * DigitRCB[j,n]);
           
            inc(d);
            setlength(linkset[n][4],d+1);
            include(linkset[n][4,d,0],n);
            linkset[n][4,d,2]:=(DigitRCB[xn,n] * Digitrcb[j,n]);
            linkset[n][4,d,1]:=(DigitRCB[xn,n] * DigitRCB[m,n]);
            include(linkset[n][4,d,3],n);
            include(linkset[n][4,d,4],m);
            include(linkset[n][4,d,5],j);           
            linkset[n][4,d,6]:=[0];
            linkset[n][4,d,7]:=[0];   
               linkset[n][4,d,9]:= DigitRCB[j,n] - (DigitRCB[xn,n] * DigitRCB[j,n]);   
               linkset[n][4,d,8]:= DigitRCB[m,n] - (DigitRCB[xn,n] * DigitRCB[m,n]);         

              end;
         
if (sec[xn,n] <6) and (Sec[xn,n] >1) and (xn in [18..26])
   then
     for J in eri[xn-18,n] do
      begin
     
      inc(e);
      setlength(linkset[n][5],e+1);
      include(linkset[n][5,e,0],n);
      linkset[n][5,e,1]:=(DigitRCB[xn,n] * Digitrcb[Rx[secset[xn,j]],n]);
      linkset[n][5,e,2]:=(DigitRCB[xn,n] * DigitRCB[Cy[secset[xn,j]]+9,n]);
      include(linkset[n][5,e,3],n);
      include(linkset[n][5,e,4], rx[secset[xn,j]]);
      include(linkset[n][5,e,5],  Cy[secset[xn,j]]+9);
       linkset[n][5,e,6]:=[0];
      linkset[n][5,e,7]:=[0];
      linkset[n][5,e,8]:= DigitRCB[Rx[secset[xn,j]],n]  - (Digitrcb[xn,n] * Digitrcb[Rx[secset[xn,j]],n]);
      linkset[n][5,e,9]:= DigitRCB[Cy[secset[xn,j]]+9,n]  - (Digitrcb[xn,n] * Digitrcb[Cy[secset[xn,j]]+9,n]);
     
      inc(e);
      setlength(linkset[n][5],e+1);
      include(linkset[n][5,e,0],n);
      linkset[n][5,e,2]:=(DigitRCB[xn,n] * Digitrcb[Rx[secset[xn,j]],n]);
      linkset[n][5,e,1]:=(DigitRCB[xn,n] * DigitRCB[Cy[secset[xn,j]]+9,n]);
      include(linkset[n][5,e,3],n);
      include(linkset[n][5,e,5], rx[secset[xn,j]]);
      include(linkset[n][5,e,4],  Cy[secset[xn,j]]+9);       
       linkset[n][5,e,6]:=[0];
      linkset[n][5,e,7]:=[0];
      linkset[n][5,e,9]:= DigitRCB[Rx[secset[xn,j]],n]  - (Digitrcb[xn,n] * Digitrcb[Rx[secset[xn,j]],n]);
      linkset[n][5,e,8]:= DigitRCB[Cy[secset[xn,j]]+9,n]  - (Digitrcb[xn,n] * Digitrcb[Cy[secset[xn,j]]+9,n]);
     
     
      end;

end;
end;
{
assign(output,'C:\sudoku\combotest.txt');
erase(output);
rewrite(output);
close(output);

for n2 in [1..9] do
for xn in [0..5] do
 for J:= low(linkset[n2][xn]) to high(linkset[n2][xn]) do
 begin
   append(output);
      writeln(output);   
         write(output,'#',n2,' | ');
          write(output,'type:',xn,' | ');     
      for n:= low(linkset[n2][xn,j]) to high(linkset[n2][xn,j]) do
       begin
          for M in linkset[n2][xn,j,n] do
        write(output,m,',');
        write(output,' | ');
      end;
      close(output);     
 end}

end;{strong link builder}

originally i had a 2ndary table of weak-links which i realized is wasted space
since a weak link only occurs on a shared sector that sees all the digits my strong link setup already included that information!

all you have to do is reference the start and end cells of the initial link
saved sectors all those cells are found in for start/end
then run your program to line up the end cells sector to the next starting sector and off to the races we go.

for reference
my solver is in free pascal using setwise operations
Some do, some teach, the rest look it up.
stormdoku
User avatar
StrmCkr
 
Posts: 1430
Joined: 05 September 2006


Return to Software