예제 #1
0
 private static void DoSolveIt(Sudoku sudoku)
 {
     Console.Write("\nShould I solve it the fast way?: ");
     var heuristic = Console.ReadKey().KeyChar.ToString().ToUpper().Equals("Y");
     Console.WriteLine("\n**SOLVING**");
     Thread.Sleep(1000);
     sudoku.BruteForce(heuristic);
     Console.WriteLine("**SOLVED**");
     sudoku.PrintBoard();
 }
예제 #2
0
 private static void DoNumberPlacer(Sudoku sudoku)
 {
     Console.WriteLine("\n*********************\n*********************");
     var done = false;
     while (!done)
     {
         sudoku.PrintBoard();
         Console.Write("\nPlease insert number to try (1-9): ");
         var userInput = Console.ReadKey().KeyChar.ToString();
         int num;
         if (!int.TryParse(userInput, out num) || num == 0)
         {
             Console.WriteLine("\n***INVALID ENTRY***");
             continue;
         }
         Console.Write("\nPlease insert x location to place (1-9): ");
         userInput = Console.ReadKey().KeyChar.ToString();
         int x;
         if (int.TryParse(userInput, out x) && x != 0)
         {
             Console.Write("\nPlease insert y location to place (1-9): ");
             userInput = Console.ReadKey().KeyChar.ToString();
             int y;
             if (int.TryParse(userInput, out y) && y != 0)
             {
                 Console.WriteLine("\n{0} can be placed at ({1}, {2}): {3}", num, x, y,
                     sudoku.NumberAt(x - 1, y - 1, num));
                 done = true;
             }
             else
             {
                 Console.WriteLine("\n***INVALID ENTRY***");
             }
         }
         else
         {
             Console.WriteLine("\n***INVALID ENTRY***");
         }
     }
 }