public void NumbersOnePlaceTest()
        {
            NineBoard testBoard = new NineBoard();

            string[] lines = File.ReadAllLines(@"E:\School Stuff\Homework\CS 5700\SudokuSolver\SudokuSolver\TestBoards\Input\Puzzle-9x9-0001.txt");
            Assert.IsNotNull(lines);
            List <char> testPuzzle = new List <char>();

            for (int i = 2; i < lines.Length; i++)
            {
                ParseSudokuPuzzle.ParsePuzzleLine(lines[i], testPuzzle);
            }
            Assert.IsNotNull(testPuzzle);
            testBoard.Init(testPuzzle);
            Assert.AreEqual(4, testBoard.Cells[0].Value);
            NumbersOnePlace             solver     = new NumbersOnePlace();
            NumbersOnePossibilitySolver onePSolver = new NumbersOnePossibilitySolver();

            solver.SolveCells(testBoard);
            NineBoard testBBB = new NineBoard();

            testBBB.Init(testPuzzle);
            ParseSudokuPuzzle.CopyBoard(testBBB, testBoard);
            onePSolver.SolveCells(testBoard);
            Assert.AreEqual(46, testBoard.SolvedCells);
            Assert.AreEqual(9, testBoard.Cells[1].Value);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string file;

            Console.WriteLine("Please Enter a FileName: ");
            file = Console.ReadLine();
            NineBoard testBoard = new NineBoard();
            // NumbersOnePlace solver = new NumbersOnePlace();
            Solver solver = new Solver();

            string[] lines = File.ReadAllLines(@file);
            solver.Init(lines);
            solver.Solve();

            /*List<char> testPuzzle = new List<char>();
             *
             * for (int i = 2; i < lines.Length; i++)
             * {
             *  ParseSudokuPuzzle.ParsePuzzleLine(lines[i], testPuzzle);
             * }
             *
             * testBoard.Init(testPuzzle);
             * solver.SolveCells(testBoard);*/
            Console.WriteLine("Done");
            Console.WriteLine("Press a key to Exit");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        public void TestNineBoard()
        {
            NineBoard testNine  = new NineBoard();
            Cell      testCell1 = new Cell(1, 1, 1);
            Cell      testCell2 = new Cell(9, 9, 9);
            Cell      testCell3 = new Cell(2, 3, 1);

            Assert.IsNotNull(testNine);
            foreach (Cell cell in testNine.Cells)
            {
                Assert.IsNotNull(cell);
                Assert.AreNotEqual(-1, cell.Box);
            }

            Assert.AreEqual(81, testNine.Cells.Count);
            Assert.AreEqual(testCell1.Row, testNine.Cells[0].Row);
            Assert.AreEqual(testCell2.Row, testNine.Cells[80].Row);
            Assert.AreEqual(testCell1.Box, testNine.Cells[0].Box);
            Assert.AreEqual(testCell2.Box, testNine.Cells[80].Box);
            Assert.AreEqual(testCell3.Row, testNine.Cells[11].Row);
            Assert.AreEqual(testCell3.Box, testNine.Cells[11].Box);
        }