コード例 #1
0
        public void SolvesSudokus()
        {
            SudokuPuzzle unsolved = SudokuPuzzle.CreateFromStream(GetStreamFromFileName(GOODSINGLEPUZZLEFILE));
            //One more time!
            SudokuPuzzle unsolved2 = SudokuPuzzle.CreateFromStream(GetStreamFromFileName(GOODSINGLEPUZZLEFILE));

            Assert.IsFalse(unsolved.IsSolved());
            SudokuPuzzle solved = new SudokuPuzzle("Solved1")
            {
                PuzzleMatrix = new int[][]
                {
                    new int[] { 4, 8, 3, 9, 2, 1, 6, 5, 7 },
                    new int[] { 9, 6, 7, 3, 4, 5, 8, 2, 1 },
                    new int[] { 2, 5, 1, 8, 7, 6, 4, 9, 3 },
                    new int[] { 5, 4, 8, 1, 3, 2, 9, 7, 6 },
                    new int[] { 7, 2, 9, 5, 6, 4, 1, 3, 8 },
                    new int[] { 1, 3, 6, 7, 9, 8, 2, 4, 5 },
                    new int[] { 3, 7, 2, 6, 8, 9, 5, 1, 4 },
                    new int[] { 8, 1, 4, 2, 5, 3, 7, 6, 9 },
                    new int[] { 6, 9, 5, 4, 1, 7, 3, 8, 2 },
                }
            };
            SudokuRoot totest = new SudokuRoot();

            totest.SolveSudoku(unsolved);
            totest.SolveSudoku(unsolved2);
            Assert.IsTrue(unsolved.IsSolved());
            Assert.IsTrue(unsolved2.IsSolved());
        }
コード例 #2
0
        public void SolvesAllTheThings()
        {
            List <SudokuPuzzle> puzzles = SudokuFile.ReadFile(GOODFILENAME);
            SudokuRoot          Solver  = new SudokuRoot();

            foreach (var puzzle in puzzles)
            {
                Solver.SolveSudoku(puzzle);
            }
            foreach (var puz in puzzles)
            {
                Assert.IsTrue(puz.IsSolved());
            }
        }