int HiddenCandidates(int blockIndex) { int totalEliminated = 0; SudokuBlock sudokuBlock = new SudokuBlock(_sudokuGrid.GetBlockScope(blockIndex)); List <SudokuCell> block = GetUnsolvedBlock(blockIndex); RankingDictionary <int> candidateRanking = GetCandidateRanking(block); List <int> hiddenSingle = candidateRanking[1]; // Index == # of occurances-1, value == candidate digit that appears that number of times List <int> hiddenPair = candidateRanking[2]; List <int> hiddenTriple = candidateRanking[3]; // List<CellEventInfo> history; if (hiddenSingle.Count != 0) { totalEliminated += HiddenSingle(block, hiddenSingle.First()); } // if(hiddenPair.Count != 0) // { // totalEliminated += ExploreHiddenSubset(hiddenPair, block); // history = _sudokuGrid.EditHistory; // } // if(hiddenTriple.Count != 0) // { // totalEliminated += ExploreHiddenSubset(hiddenTriple, block); // history = _sudokuGrid.EditHistory; // } return(totalEliminated); }
// CONSTRUCTORS internal SudokuPuzzle() { this.Grid = new SudokuCell[9, 9]; this.Rows = new SudokuRow[9]; this.Columns = new SudokuColumn[9]; this.Blocks = new SudokuBlock[3, 3]; this.Errors = 0; this.Values = 81; for (int i = 0; i < 9; i++) { Rows[i] = new SudokuRow(); } for (int i = 0; i < 9; i++) { Columns[i] = new SudokuColumn(); } for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { Blocks[x, y] = new SudokuBlock(); } } }
public SudokuBlock Find(int row, int col) { SudokuBlock sudokuBlock = new SudokuBlock(); //first col conditions if ((row >= 0 && row <= 2) && (col >= 0 && col <= 2)) { sudokuBlock.startRow = 0; sudokuBlock.startCol = 0; } else if ((row >= 3 && row <= 5) && (col >= 0 && col <= 2)) { sudokuBlock.startRow = 3; sudokuBlock.startCol = 0; } else if ((row >= 6 && row <= 8) && (col >= 0 && col <= 2)) { sudokuBlock.startRow = 6; sudokuBlock.startCol = 0; } //second col conditions else if ((row >= 0 && row <= 2) && (col >= 3 && col <= 5)) { sudokuBlock.startRow = 0; sudokuBlock.startCol = 3; } else if ((row >= 3 && row <= 5) && (col >= 3 && col <= 5)) { sudokuBlock.startRow = 3; sudokuBlock.startCol = 3; } else if ((row >= 6 && row <= 8) && (col >= 3 && col <= 5)) { sudokuBlock.startRow = 6; sudokuBlock.startCol = 3; } //third col cond itions else if ((row >= 0 && row <= 2) && (col >= 6 && col <= 8)) { sudokuBlock.startRow = 0; sudokuBlock.startCol = 6; } else if ((row >= 3 && row <= 5) && (col >= 6 && col <= 8)) { sudokuBlock.startRow = 3; sudokuBlock.startCol = 6; } else if ((row >= 6 && row <= 8) && (col >= 6 && col <= 8)) { sudokuBlock.startRow = 6; sudokuBlock.startCol = 6; } return(sudokuBlock); }
public SudokuSolver(SudokuState sudokuState, SudokuBlock sudokuBlock) { _sudokuState = sudokuState; _sudokuBlock = sudokuBlock; }
public BruteForce(SudokuBlock sudokuBlock) { _sudokuBlock = sudokuBlock; }