public void SolvePuzzles() { Puzzle puzzle = null; List<char[]> OriginalCellValues = null; StrategySolver solver = new StrategySolver(); solver.Strategies.Add(new Comprehensive()); PuzzleInitializer initializer = new FileInitializer(); initializer.PuzzleFilePath = Server.MapPath("~") + @"..\puzzles\"; initializer.InitializePuzzle(out puzzle); if (puzzle.ErrorMessage == null) { OriginalCellValues = GetPuzzleCellValues(puzzle); solver.Solve(puzzle); } if(puzzle.ErrorMessage != null) { ReportError(puzzle.ErrorMessage); } else { List<char[]> SolvedCellValues = GetPuzzleCellValues(puzzle); WritePuzzle(puzzle, OriginalCellValues, SolvedCellValues); } }
static void Main(string[] args) { StrategySolver solver = new StrategySolver(); // TODO: (DONE) Add strategies solver.Strategies.Add(new Comprehensive()); // TODO: (DONE) Initialize puzzle from file Puzzle puzzle = null; PuzzleInitializer initializer = new FileInitializer(); initializer.InitializePuzzle(out puzzle); if (puzzle.ErrorMessage == null) { Console.WriteLine(puzzle.ToString().Replace('0', ' ')); solver.Solve(puzzle); } if (puzzle.ErrorMessage != null) { Console.WriteLine(puzzle.ErrorMessage); } else { Console.Write(puzzle); } Console.WriteLine(); Console.WriteLine("Press <ENTER> to continue."); Console.ReadLine(); }
static void Main(string[] args) { StrategySolver solver = new StrategySolver(); // TODO: Add strategies // TODO: Initialize puzzle from file Puzzle puzzle = null; solver.Solve(puzzle); Console.Write(puzzle); Console.WriteLine(); Console.WriteLine("Press <ENTER> to continue."); Console.ReadLine(); }