private bool ValueExistsInColumn(ISudokuPosition position, int value) { int squareSize = Puzzle.Size * Puzzle.Size; ISudokuPosition currentPosition = new SudokuPosition(); currentPosition.ColumnNumber = position.ColumnNumber; for (int i = 0; i < squareSize; i++) { currentPosition.RowNumber= i; if (Puzzle.GetValue(currentPosition) == value) { return true; } } return false; }
private void InitializeValuesTable() { valuesTable = new Dictionary<ISudokuPosition, IValueCyclableCollection>(); int squareSize = Puzzle.Size * Puzzle.Size; ISudokuPosition currentPosition; // Create an entry for each position for (int i = 0; i < squareSize; i++) { for (int j = 0; j < squareSize; j++) { currentPosition = new SudokuPosition(); currentPosition.RowNumber = i; currentPosition.ColumnNumber = j; valuesTable.Add(currentPosition, CreateValueCyclableCollection(currentPosition)); } } }
private bool ValueExistsInRegion(ISudokuPosition position, int value) { ISudokuRegion region = Puzzle.GetRegionByValuePosition(position); ISudokuPosition currentPosition = new SudokuPosition(); for (int i = 0; i < region.Size; i++) { currentPosition.RowNumber = i; for (int j = 0; j < region.Size; j++) { currentPosition.ColumnNumber = j; if (region.GetValue(currentPosition) == value) { return true; } } } return false; }