SEclone  XYWing XYZWing


The process for XYWings and XYZWings is also a copy of my solver


These process and others (UL and BUGs we will see later ) are using a table of cells having 2 candidates;

Before entering the XYWing process, that table is created and a copy of the main table of cells is done.

The TPAIRES class is a file containing also a class designed for UL processing that we will see later. The class TPAIRES has only one member, “zpaires”


#include "c\_04d_  paires.cpp" 


Here is the code for that class. Most of the data included in that class refer to UL and BUG process;




// class collecting cell with 2 digits to find XWings and XYZ wings

// basis for all kinds of bugs as well

// also used in tagging to establish corresponding stong links

class PAIRES

 {public: CB9CH pa; USHORT i8;

  void Charge(P81 & p8) {pa=p8.v.cand;i8=p8.f->i8;};






 PAIRES zp[80],zpt[80];  // collection of bivalues in cells

 int izpd[50];           // start/end index in zp for tp table

 CB9CH tp[50],           // collection of different possibilities for bivalues in cells

       el_par_ch[27],    // parity fo digits in pairs in any elements

       candp_or,         // within an elem parity or for paired cells

          candnp_or,        // same for non paired cells

          candp_xor,        // parity for paired (redundancy)

          candnp_xor,       // parity for non paired cells

          wplus[10];        // CB9CH within the element for non pair cells (virtual clearing)


 ZINFL zplus;            // cells with more than 2

 int tplus[10],ntplus;    // same in table limited to 8

 USHORT tpa[10],         // table for pairs in tha active row/col/bx

           ntpa,            // and number of pairs

        nwp;             // index for wplus

 int ip,np,aigpmax,aigun;

 void CreerTable();

 int CommunPaires (int i, int j){return T81t[zp[i].i8].ObjCommun (& T81t[zp[j].i8]) ;}

 int CommunTrio (int i, int j){return T81t[i].ObjCommun (& T81t[zp[j].i8]) ;}

 int XYWing();

 int XYZWing();

 int UL();           // called in SE for type 1 storing others

 int BUG();  // process all bugs forms

 int Bug1(); int Bug2(); int Bug3(int el);int Bug_lock(int el);

 int Bug3_4_Nacked(int el);

 int Nacked_Go(CB9CH welim);

 void BugMess(char * lib);

 void CommunLib (int i,int j,int k,char * lib)

   {if(!o$.ot) return;

    E$.E(lib);  E$.E(t81f[k].pt);E$.E(" ");E$.E(T81t[k].scand);  

    E$.E(" (1)=");E$.E(t81f[zp[i].i8].pt);E$.E(" ");E$.E(T81t[zp[i].i8].scand);

    E$.E(" (2)=");E$.E(t81f[zp[j].i8].pt);E$.E(" ");E$.Enl(T81t[zp[j].i8].scand); 




} zpaires;


The code to create the table is in the file


#include "c\_04d_  paires.cpp" 


In that steps, we only nees the collection of dual cells.




void TPAIRES::CreerTable()

{ip=0; ntplus=aigpmax=0; zplus.Init();

 for(int i=0;i<81;i++)

   {int n=T81t[i].v.ncand;

       if(n==2)    {zp[ip].Charge(T81t[i]);  zpt[ip]=zp[ip++];}

    else if(n>2)

     {if(ntplus<8) {tplus[ntplus]=i;//direct access to first plus cells

                        ntplus++;   zplus.Set(i);}

      if(n>aigpmax) aigpmax=n;}


 // now sorting the table zpt for the search of UR/UL

 for(int i=0;i<ip-1;i++) for(int j=i+1;j<ip;j++)


              ||(zpt[j].pa.f==zpt[i].pa.f  && zpt[j].i8<zpt[i].i8) )

 {PAIRES temp=zpt[i]; zpt[i]=zpt[j]; zpt[j]=temp;}

 // and final entries in tp izpd izpf

 np=0; if(!ip) return; tp[0]=zpt[0].pa;izpd[0]=0;

 for(int i=1;i<ip;i++)







XYWing XYZWing


The code for these two steps is is the file



#include "c\_04d_  xyw.cpp"


It is exactly the code in use in my solver.



//<<<<<<<<<<<<<<<<<<<< // depart deux paires pas objet commun et trio

int TPAIRES::XYWing() // troisieme par les isoles  objets  communs

{int ir=0;   

 for(int i=0;i<ip-1;i++)

 for(int j=i+1;j<ip;j++)

    { if(CommunPaires(i,j)) continue;

      CB9CH w=zp[i].pa|zp[j].pa;  if(w.QC()-3) continue;

      CB9CH w1=(zp[i].pa&zp[j].pa),w2=w1 ^ w;  // les deux non communs

       for(int k=0;k<ip;k++)

        {if( zp[k].pa.f-w2.f) continue; // il faut =

         if(!CommunPaires(i,k)) continue;

         if(!CommunPaires(j,k)) continue;

         // on a un XYWing  potentiel

         int ich=w1.First(); // le chiffre

         ZINFL z1= t81f[zp[i].i8].z & t81f[zp[j].i8].z ,

               z2=z1&jdk.c[ich]  ;  // z2 est à supprimer

         if(z2.NonNul() )

         {    CommunLib(i,j,zp[k].i8,"->XY WING pivot= ");  T81->Clear(z2,ich); return 1;  }

     }      }

 return ir;}

 //<<<<<<<<<<<<<<<<<<<< // depart deux paires pas objet commun et trio

int TPAIRES::XYZWing() // troisieme est le trio objets communs

{int ir=0; 

 for(int i=0;i<ip-1;i++)

  for(int j=i+1;j<ip;j++)

   { if(CommunPaires(i,j)) continue;

     CB9CH w=zp[i].pa|zp[j].pa;  if(w.QC()-3) continue;

     CB9CH w1=(zp[i].pa&zp[j].pa);  // le chiffre

      for(int k=0;k<81;k++)

            {if(T81t[k].v.cand.f-w.f) continue; // il faut = trio

        if(!CommunTrio(k,i)) continue;

        if(!CommunTrio(k,j)) continue;

        // on a un XYZWing  potentiel

        int ich=w1.First(); // le chiffre

        ZINFL z1= t81f[zp[i].i8].z & t81f[zp[j].i8].z & t81f[k].z,

              z2=z1&jdk.c[ich]  ;  // z2 est à supprimer

        if(z2.NonNul() ) 

          {CommunLib(i,j,k,"->XYZ WING pivot= ");  T81->Clear(z2,ich); return 1;   }

    }   }

 return ir;}