public SudokuSolver(int[,] initialGrid) { m_grid = new int[9, 9]; m_cellConstraintMatrix = new Candidate[9, 9]; m_rowConstraintMatrix = new Candidate[9]; m_colConstraintMatrix = new Candidate[9]; m_regionConstraintMatrix = new Candidate[9, 9]; solved = new HashSet<Cell>(); unsolved = new HashSet<Cell>(); changed = new Stack<HashSet<Cell>>(); bucketList = new HashSet<Cell>[10]; steps = 0; // initialize constraints for (int row = 0; row < 9; row++) { for (int col = 0; col < 9; col++) { // copy grid, and turn on all Candidates for every cell m_grid[row, col] = initialGrid[row, col]; m_cellConstraintMatrix[row, col] = new Candidate(9, true); } } for (int i = 0; i < 9; i++) { m_rowConstraintMatrix[i] = new Candidate(9, false); m_colConstraintMatrix[i] = new Candidate(9, false); bucketList[i] = new HashSet<Cell>(); } bucketList[9] = new HashSet<Cell>(); for (int row = 0; row < 3; row++) for (int col = 0; col < 3; col++) m_regionConstraintMatrix[row, col] = new Candidate(9, false); InitializeMatrices(); PopulateCandidates(); }
public CandidateEnumerator(Candidate c) { m_c = c; m_position = 0; }