public void TestMethod1() { int[,] problem = null; string[] x = new string[] { "060200109", "308007000", "050903007", "903070610", "000806000", "046090503", "500301090", "000700204", "602009050", }; problem = InitializeProblemFromString(x); var sb = new System.Text.StringBuilder(); var tw = new System.IO.StringWriter(sb); var solver = new SolveSudoku.SudokuSolver(); solver.PrintSolution(problem, tw); var result = solver.Solve(problem); Assert.IsNotNull(result); foreach(int[,] r in solver.GetAllAnswers()) { VerifySolution(r); } sb.Clear(); tw.Dispose(); sb.Clear(); }
public void TestMethod2() { int[,] problem = null; string[] x = new string[] { "006020100", "000617000", "710000095", "100352009", "403000502", "900784001", "650000023", "000269000", "009070400", }; problem = InitializeProblemFromString(x); var sb = new System.Text.StringBuilder(); var tw = new System.IO.StringWriter(sb); var solver = new SolveSudoku.SudokuSolver(); solver.PrintSolution(problem, tw); var result = solver.Solve(problem); Assert.IsNotNull(result); foreach (int[,] r in solver.GetAllAnswers()) { VerifySolution(r); } sb.Clear(); tw.Dispose(); sb.Clear(); }
static void Main(string[] args) { int[,] problem = new int[9, 9]; string[] x = new string[] { "060200109", "308007000", "050903007", "903070610", "000806000", "046090503", "500301090", "000700204", "602009050", }; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { problem[i, j] = x[i][j] - '0'; } } var solver = new SolveSudoku.SudokuSolver(); solver.PrintSolution(problem, Console.Out); var result = solver.Solve(problem); solver.PrintSolution(result, Console.Out); }