/// <summary>
        /// Attempt to advance the <see cref="SudokuPuzzle"/> by finding regions (i.e. blocks, rows, or columns)
        /// where only one <see cref="Cell"/> has not been solved, then solving that <see cref="Cell"/>
        /// </summary>
        /// <param name="puzzle">The <see cref="SudokuPuzzle"/> being advanced</param>
        /// <param name="candidateCells">A list of <see cref="Cell"/>s, each of which is the single unsolved cell in a region</param>
        /// <returns>Whether the <see cref="SudokuPuzzle"/> ends up being advanced</returns>
        protected override bool MessWithPuzzle(SudokuPuzzle puzzle, List <Cell> candidateCells)
        {
            bool hasAdvanced = false;

            for (int i = 0; i < candidateCells.Count; ++i)
            {
                if (this.SolveCell(candidateCells[i], puzzle.GetAllAllowedValues()))
                {
                    hasAdvanced = true;
                }
            }

            return(hasAdvanced);
        }
Пример #2
0
        public void TestAllowedValues()
        {
            int        dimension  = 3;
            List <int> cellValues = new List <int>();

            for (int i = 0; i < dimension * dimension * dimension * dimension; ++i)
            {
                cellValues.Add(0);
            }

            SudokuPuzzle puzzle = new SudokuPuzzle(dimension, cellValues);

            List <int> allowedValues = puzzle.GetAllAllowedValues();

            for (int i = 0; i < dimension * dimension; ++i)
            {
                Assert.IsTrue(allowedValues[i] == i + 1);
            }
        }