private int GroupedNLEx_CheckSolution(USuperLink GNL_Result, ref int contDiscontF) { bool SolFound = false; GroupedLink GLKnxt = GNL_Result.resultGLK; if (GLKnxt == null) { return(-1); //Not established } List <GroupedLink> SolLst = Convert_ChainToList_GNL(GNL_Result); if (SolLst == null || SolLst.Count < 2) { return(-1); //Not established } GroupedLink GLKorg = SolLst[0]; bool SolType = Check_SuperLinkSequence(GLKnxt, GLKorg); //true:Continuous false:DisContinuous contDiscontF = SolType? 1: 2; if (SolType) //==================== continuous ==================== { Bit81 UsedCs = SolLst.Aggregate(new Bit81(), (Q, P) => Q | P.UGCellsB.B81); foreach (var LK in SolLst.Where(P => (P.type == W))) { int noB = 1 << LK.no; Bit81 SolBP = new Bit81(); LK.UGCellsA.ForEach(P => { if ((P.FreeB & noB) > 0) { SolBP.BPSet(P.rc); } }); LK.UGCellsB.ForEach(P => { if ((P.FreeB & noB) > 0) { SolBP.BPSet(P.rc); } }); if (SolBP.BitCount() <= 1) { continue; } foreach (var P in pBDL.Where(p => (p.FreeB & noB) > 0)) { if (UsedCs.IsHit(P.rc)) { continue; } if (!(SolBP - ConnectedCells[P.rc]).IsZero()) { continue; } if ((P.FreeB & noB) == 0) { continue; } P.CancelB |= noB; �@�@//exclusion digit
public UGLink(Bit81 rcBit81) { this.SrNum = SrNum0++; this.rcBit81 = rcBit81; this.sz = rcBit81.BitCount(); rcbn2 = new Bit981(rcBit81); rcbn_conn2 = new Bit981(); var _conn = new Bit81(); foreach (var rc in rcBit81.IEGet_rc()) { _conn |= p_connectedCells[rc]; for (int n = 0; n < 9; n++) { rcbn_conn2.BPSet(n, rc); } } int no = rcBit81.no; rcbn_conn2._BQ[no] = _conn - rcBit81; rcbnFrame2 = (long)rcBit81.Get_RowColumnBlock() | ((long)1 << (no + 27)); //■ }
private int _GroupedNL_CheckSolution(GroupedLink GLK0, GroupedLink GLKnxt, Stack <GroupedLink> SolStack, Bit81 UsedCs) { bool SolFound = false; int SolType = pSprLKsMan.Check_SuperLinkSequence(GLKnxt, GLK0)? 1: 2; //1:Continuous 2:DisContinuous if (SolType == 1) //<>continuous { List <GroupedLink> SolLst = SolStack.ToList(); //___Debug_Print_GNLChain(SolStack); SolLst.Reverse(); SolLst.Add(GLK0); Bit81 UsedCsTmp = new Bit81(UsedCs); SetUsed(ref UsedCsTmp, GLKnxt); foreach (var LK in SolLst.Where(P => (P.type == W))) { int noB = 1 << LK.no; Bit81 SolBP = new Bit81(); LK.UGCellsA.ForEach(P => { if ((P.FreeB & noB) > 0) { SolBP.BPSet(P.rc); } }); LK.UGCellsB.ForEach(P => { if ((P.FreeB & noB) > 0) { SolBP.BPSet(P.rc); } }); if (SolBP.BitCount() <= 1) { continue; } foreach (var P in pBDL.Where(p => (p.FreeB & noB) > 0)) { if (UsedCsTmp.IsHit(P.rc)) { continue; } if (!(SolBP - ConnectedCells[P.rc]).IsZero()) { continue; } if ((P.FreeB & noB) == 0) { continue; } P.CancelB |= noB; //exclusion digit SolFound = true; } } var LKpre = SolLst[0]; foreach (var LK in SolLst.Skip(1)) { if (LKpre.type == S && LK.type == S && LK.UGCellsA.Count == 1) { var P = pBDL[LK.UGCellsA[0].rc]; //(for MultiAns code) int noB2 = P.FreeB - ((1 << LKpre.no2) | (1 << LK.no)); if (noB2 > 0) { P.CancelB |= noB2; SolFound = true; } } LKpre = LK; } if (SolFound) { SolCode = 1; } } else { //<>discontinuous int dcTyp = GLK0.type * 10 + GLKnxt.type; UCell P = pBDL[GLK0.UGCellsA[0].rc]; //(for MultiAns code) switch (dcTyp) { case 11: P.FixedNo = GLK0.no + 1; //Cell number determination P.CancelB = P.FreeB.DifSet(1 << (GLK0.no)); SolCode = 1; SolFound = true; //(1:Fixed) break; case 12: P.CancelB = 1 << GLKnxt.no; SolCode = 2; SolFound = true; break;//(2:Exclude from candidates) case 21: P.CancelB = 1 << GLK0.no; SolCode = 2; SolFound = true; break; case 22: if (GLK0.no == GLKnxt.no) { P.CancelB = 1 << GLK0.no; SolFound = true; SolCode = 2; } break; } } if (SolFound) { return(SolType); } return(-1); }