Example #1
0
 public static void EliminateDuplicates(SudokuModel model, int col, int row)
 {
     if (model.IsSolved(col, row)) {
         var value = model.GetValue(col, row);
         foreach (var region in model.GetIntersectingRegions(col, row)) {
             foreach (var other in model.GetCells(region.Type, region.I)) {
                 if (other.Column != col || other.Row != row) {
                     model.Eliminate(other.Column, other.Row, value);
                 }
             }
         }
     }
 }
Example #2
0
 protected override void OperateOn(SudokuModel model)
 {
     // We could look at all 2^N possible sets on all 3N of the model's regions,
     // but it is more efficient to only use the
     // possiblity set of each cell, and isolate that set on each intersecting region.
     for (var row = 0; row < model.Size; ++row) {
         for (var col = 0; col < model.Size; ++col) {
             if (!model.IsSolved(col, row)) {
                 foreach (var region in model.GetIntersectingRegions(col, row)) {
                     var checkedIter = GetCheckedIteration(region);
                     if (checkedIter < model.GetLastChangedIterRegion(region.Type, region.I)) {
                         _checkedIteration[region] = checkedIter;
                         IsolateSet(model.GetPossibilitySetCell(col, row), region, model);
                     }
                 }
             }
         }
     }
 }