Beispiel #1
0
 bool OperateOn(int col, int row, SudokuModel model)
 {
     if (!model.IsSolved(col, row)) {
         // obviously can't eliminate anything in a solved cell.
         // try each int i that is a possibility for the cell, and see if an error results
         foreach (var i in model.GetPossibilitySetCell(col, row).HighBitPositions()) {
             var clone = new SudokuModel(model);
             clone.SetValue(col, row, i);
             _elimStrategy.Run(clone);
             if (clone.IsConsistent()) {
                 continue;
             }
             // If so, we can eliminate that from the original model.
             model.Eliminate(col, row, i);
             return true;
             // return immediately after eliminating something, since
             // this is a slow algorithm, and we want our faster
             // algorithms to see if they make some more eliminations first.
         }
     }
     return false;
 }