/// <inheritdoc/> public override void GetAll(IBag <TechniqueInfo> accumulator, IReadOnlyGrid grid) { var r = (Span <int>) stackalloc int[2]; foreach (var((baseSet, coverSet), (a, b, c)) in IntersectionMaps) { if (!EmptyMap.Overlaps(c)) { continue; } short m1 = BitwiseOrMasks(grid, a); short m2 = BitwiseOrMasks(grid, b); short m3 = BitwiseOrMasks(grid, c); short m = (short)(m3 & (m1 ^ m2)); if (m == 0) { continue; } foreach (int digit in m.GetAllSets()) { GridMap elimMap; (r[0], r[1], elimMap) = a.Overlaps(CandMaps[digit]) ? (coverSet, baseSet, a & CandMaps[digit]) : (baseSet, coverSet, b & CandMaps[digit]); if (elimMap.IsEmpty) { continue; } var conclusions = new List <Conclusion>(); foreach (int cell in elimMap) { conclusions.Add(new Conclusion(Elimination, cell, digit)); } var candidateOffsets = new List <(int, int)>(); foreach (int cell in c& CandMaps[digit]) { candidateOffsets.Add((0, cell * 9 + digit)); } accumulator.Add( new LcTechniqueInfo( conclusions, views: new[]
/// <summary> /// Search for all W-Wings. /// </summary> /// <param name="result">The result accumulator.</param> /// <param name="grid">The grid.</param> /// <returns>All technique information instances.</returns> public static void TakeAllWWings(IBag <TechniqueInfo> result, IReadOnlyGrid grid) { if (BivalueMap.Count < 2) { return; } // Iterate on each cells. for (int c1 = 0; c1 < 72; c1++) { if (!BivalueMap[c1] || !EmptyMap[c1]) { continue; } // Iterate on each cells which are not peers in 'c1'. int[] digits = grid.GetCandidatesReversal(c1).GetAllSets().ToArray(); foreach (int c2 in BivalueMap - new GridMap(c1)) { if (c2 < c1 || grid.GetCandidatesReversal(c1) != grid.GetCandidatesReversal(c2)) { continue; } var intersection = new GridMap(c1, false) & new GridMap(c2, false); if (!EmptyMap.Overlaps(intersection)) { continue; } for (int region = 9; region < 27; region++) { if (region < 18 && ( GetRegion(c1, RegionLabel.Row) == region || GetRegion(c2, RegionLabel.Row) == region) || region >= 18 && ( GetRegion(c1, RegionLabel.Column) == region || GetRegion(c2, RegionLabel.Column) == region)) { continue; } SearchWWingByRegions(result, grid, digits, region, c1, c2, intersection); } } } }