public int SudokuSpice()
        {
            var generator = new StandardPuzzleGenerator();
            PuzzleWithPossibleValues puzzle = generator.Generate(9, 30, TimeSpan.FromSeconds(10));

            return(puzzle.NumEmptySquares);
        }
        public void Generate_WithShortTimeout_ThrowsTimeoutException()
        {
            var generator = new StandardPuzzleGenerator();

            Assert.Throws <TimeoutException>(
                () => generator.Generate(16, 150, TimeSpan.FromMilliseconds(1)));
        }
        public void Generate_WithInvalidNumToSet_Throws(int size, int numToSet)
        {
            var generator = new StandardPuzzleGenerator();

            Assert.Throws <ArgumentOutOfRangeException>(
                () => generator.Generate(size, numToSet, TimeSpan.FromSeconds(60)));
        }
Exemple #4
0
        public int SudokuSpice()
        {
            var    generator = new StandardPuzzleGenerator(9);
            Puzzle puzzle    = generator.Generate(30, TimeSpan.FromSeconds(10));

            return(puzzle.NumEmptySquares);
        }
        public void Generate_CreatesPuzzleWithUniqueSolution(int size, int numToSet)
        {
            var generator = new StandardPuzzleGenerator();

            PuzzleWithPossibleValues puzzle = generator.Generate(size, numToSet, TimeSpan.FromSeconds(60));

            Assert.Equal(size * size - numToSet, puzzle.NumEmptySquares);
            var        solver = StandardPuzzles.CreateSolver();
            SolveStats stats  = solver.ComputeStatsForAllSolutions(puzzle);

            Assert.Equal(1, stats.NumSolutionsFound);
        }
        public void Generate_WithInvalidPuzzleSize_Throws(int size)
        {
            var generator = new StandardPuzzleGenerator();

            Assert.Throws <ArgumentException>(() => generator.Generate(size, 1, TimeSpan.FromSeconds(60)));
        }