Пример #1
0
 private void RemoveTrialSquarePossibleValue(PuzzleSquare source, Int32 value)
 {
     source.TrialPossibleValues.Remove(value);
     if (source.TrialPossibleValues.Count.Equals(1))
     {
         source.TrialKnownValue = source.TrialPossibleValues.FirstOrDefault();
         RemoveTrialSquareConflictPossibleValues(source);
     }
 }
Пример #2
0
 private bool GetTrialSquarePossibleValues(PuzzleSquare source)
 {
     List<Int32> conflictValues = (from square in trialKnownSquares where !square.CellIndex.Equals(source.CellIndex) && (square.RowIndex.Equals(source.RowIndex) || square.ColumnIndex.Equals(source.ColumnIndex) || square.GroupIndex.Equals(source.GroupIndex)) select square.TrialKnownValue).ToList();
     conflictValues.ForEach(value => source.TrialPossibleValues.Remove(value));
     if (source.TrialPossibleValues.Count.Equals(1))
     {
         source.TrialKnownValue = source.TrialPossibleValues.First();
         RemoveTrialSquareConflictPossibleValues(source);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #3
0
 private void RemoveTrialSquareConflictPossibleValues(PuzzleSquare source)
 {
     if (source.TrialKnownValue.Equals(0)) { return; }
     List<PuzzleSquare> conflicts = (from square in trialUnknownSquares where !square.CellIndex.Equals(source.CellIndex) && (square.RowIndex.Equals(source.RowIndex) || square.ColumnIndex.Equals(source.ColumnIndex) || square.GroupIndex.Equals(source.GroupIndex)) select square).Distinct().ToList();
     conflicts.ForEach(square => RemoveTrialSquarePossibleValue(square, source.TrialKnownValue));
 }
Пример #4
0
 private bool GetSquarePossibleValues(PuzzleSquare source)
 {
     //source.PossibleValues = new List<Int32> { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
     List<Int32> conflictValues = (from square in knownSquares where !square.CellIndex.Equals(source.CellIndex) && (square.RowIndex.Equals(source.RowIndex) || square.ColumnIndex.Equals(source.ColumnIndex) || square.GroupIndex.Equals(source.GroupIndex)) select square.KnownValue).ToList();
     conflictValues.ForEach(value => source.PossibleValues.Remove(value));
     if (source.PossibleValues.Count.Equals(1))
     {
         source.KnownValue = source.PossibleValues.FirstOrDefault();
         RemoveSquareConflictPossibleValues(source);
         return true;
     }
     else
     {
         return false;
     }
 }