private void ScanRegion(RegionQueue regions, MutablePuzzle puzzle, Region region) { var placedDigits = region.GetPlacedDigits(); for (int i = 1; i <= Puzzle.LineLength; i++) { var digit = SudokuValues.FromHumanValue(i); if (placedDigits.HasAnyOptions(digit)) { continue; } var positions = region.GetPositions(digit); if (positions.IsSingle) { var index = positions.ToIndex(); var coords = region.GetCoordinate(index); var update = new CellUpdate(digit.Invert(), coords); puzzle.RemoveOptions(update); regions.Enqueue(RegionType.Row, coords.Row); regions.Enqueue(RegionType.Column, coords.Column); regions.Enqueue(RegionType.Box, coords.Box); } } }
private void ScanRegion(RegionQueue regions, MutablePuzzle puzzle, Region region) { var placedDigits = region.GetPlacedDigits(); for (int i = 0; i < Puzzle.LineLength; i++) { var cell = region[i]; if (!cell.IsSingle && cell.HasAnyOptions(placedDigits)) { var coords = region.GetCoordinate(i); puzzle.RemoveOptions(coords, placedDigits); var newCell = cell.RemoveOptions(placedDigits); if (newCell.IsSingle) { // since we have placed a digit we must // scan these regions again regions.Enqueue(RegionType.Row, coords.Row); regions.Enqueue(RegionType.Column, coords.Column); regions.Enqueue(RegionType.Box, coords.Box); } } } }
public void ApplyToRegionQueue(RegionQueue queue) { queue.Enqueue(RegionType.Row, _update.Coordinate.Row); queue.Enqueue(RegionType.Column, _update.Coordinate.Column); queue.Enqueue(RegionType.Box, _update.Coordinate.Box); }