public void SolveAFile(string filePath)
{
string line;
System.IO.StreamReader file =
new System.IO.StreamReader(filePath);
int currentLineIndex = 0;
while ((line = file.ReadLine()) != null)
{
string[] sudokulineElements = line.Split(',');
string inputProblem = sudokulineElements[0];
string expectedSolution = sudokulineElements[1];
Sudoku.Sudoku sudoku = new Sudoku.Sudoku(inputProblem);
//RenderNewEntries(sudoku, Color.Black);
//MessageBox.Show($"Problem {counter} loaded from DB. Click to Solve ");
bool isSovled = sudoku.Solve();
string solution = sudoku.ToString();
if (isSovled)
{
if (!solution.Equals(expectedSolution))
{
throw new Exception($"Sudoku solution does not match input solution excped: {expectedSolution}.\n Actual {solution}");
}
Console.WriteLine("Solved a Problem. Rating=" + sudoku.DifficultyRating);
}
else
{
throw new Exception($"Sudoku could not be solved. Incompelete solution is {solution} expected solution was {expectedSolution}");
}
currentLineIndex++;
}
file.Close();
}