static void Main(string[] args)
        {
            SudokuWriter        sudokuWriter = new SudokuWriter();
            ImmutableSudokuGrid filledGrid   = sudokuWriter.CreateFilledGrid();

            filledGrid.PrintGrid();

            Console.WriteLine("\n");

            ImmutableSudokuGrid emptiedGrid = sudokuWriter.EmptyGridForHardSolve(filledGrid);

            emptiedGrid.PrintGrid();

            Console.WriteLine("\n");

            SudokuGrid   mutableEmptiedGrid = emptiedGrid.MakeMutableCopy();
            SudokuSolver sudokuSolver       = new SudokuSolver();

            sudokuSolver.Solve(mutableEmptiedGrid);
            mutableEmptiedGrid.PrintGrid();

            if (mutableEmptiedGrid.FindAllEmptySquares().Count != 0)
            {
                Console.WriteLine("\n");
                HarderSudokuSolver  harderSolver = new HarderSudokuSolver();
                ImmutableSudokuGrid solvedGrid   = harderSolver.Solve(emptiedGrid);
                solvedGrid.PrintGrid();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Do you want me to try and solve an Easy Sudoku (type 1) or a Very Hard Sudoku (type 2)?");
            string difficulty = Console.ReadLine();

            if (difficulty == "1")
            {
                difficulty = "Easy";
            }
            else if (difficulty == "2")
            {
                difficulty = "VeryHard";
            }
            else
            {
                Console.WriteLine("Stop being difficult.  I'm going to solve an easy one then...");
                difficulty = "Easy";
            }

            ImmutableSudokuGrid grid = new ImmutableSudokuGrid(@"..\..\..\" + difficulty + @"Sudoku.txt");

            if (grid.Elements == null)
            {
                Console.WriteLine("Error, cannot read grid from file.");
                return;
            }

            HarderSudokuSolver sudokuSolver = new HarderSudokuSolver();

            sudokuSolver.Solve(grid).PrintGrid();
        }
 public void InitializeTests()
 {
     sudokuSolver = new HarderSudokuSolver();
 }