diff --git a/src/Sudoku.Console/BulkSolver.cs b/src/Sudoku.Console/BulkSolver.cs index a2e0ad4..71dce6d 100644 --- a/src/Sudoku.Console/BulkSolver.cs +++ b/src/Sudoku.Console/BulkSolver.cs @@ -205,12 +205,14 @@ public void Solve(bool quiet = false, bool noSummary = false) i++; - if (i == 4) + if (i != 4) { - System.Console.WriteLine(); - - i = 0; + continue; } + + System.Console.WriteLine(); + + i = 0; } if (i > 0) @@ -263,7 +265,7 @@ private void ShowProgress(int solved, bool noSummary) Monitor.Exit(_consoleLock); } - private static void DumpHistory(int[] puzzle, IReadOnlyList solution, HistoryType historyType) + private static void DumpHistory(int[] puzzle, IReadOnlyCollection solution, HistoryType historyType) { int yIncrement; diff --git a/src/Sudoku.Console/ConsoleApplication.cs b/src/Sudoku.Console/ConsoleApplication.cs index 81802f7..a228493 100644 --- a/src/Sudoku.Console/ConsoleApplication.cs +++ b/src/Sudoku.Console/ConsoleApplication.cs @@ -254,7 +254,7 @@ private void GeneratePuzzles() return; } - if (clues < 17 || clues > 72) + if (clues is < 17 or > 72) { Out("\n Invalid input."); diff --git a/src/Sudoku.Console/ConsoleSolveVisualiser.cs b/src/Sudoku.Console/ConsoleSolveVisualiser.cs index f792461..8d2a798 100644 --- a/src/Sudoku.Console/ConsoleSolveVisualiser.cs +++ b/src/Sudoku.Console/ConsoleSolveVisualiser.cs @@ -111,14 +111,14 @@ private void Run() { var key = Out.ReadKey(true).KeyChar; - if (key is '<' or ',' && _speedIndex > 0) + switch (key) { - _speedIndex--; - } - - if (key is '>' or '.' && _speedIndex < _speeds.Length - 1) - { - _speedIndex++; + case '<' or ',' when _speedIndex > 0: + _speedIndex--; + break; + case '>' or '.' when _speedIndex < _speeds.Length - 1: + _speedIndex++; + break; } } } diff --git a/src/Sudoku.Console/FileHelper.cs b/src/Sudoku.Console/FileHelper.cs index 3c3d9db..7b4a26e 100644 --- a/src/Sudoku.Console/FileHelper.cs +++ b/src/Sudoku.Console/FileHelper.cs @@ -18,11 +18,6 @@ public static string GetSupportingFilesPath() { const string path = "Supporting Files"; - if (Path.Exists(path)) - { - return path; - } - - return $"src/Sudoku.Console/{path}"; + return Path.Exists(path) ? path : $"src/Sudoku.Console/{path}"; } } \ No newline at end of file diff --git a/src/Sudoku/Solver.cs b/src/Sudoku/Solver.cs index 4e6515e..860305e 100644 --- a/src/Sudoku/Solver.cs +++ b/src/Sudoku/Solver.cs @@ -64,12 +64,9 @@ public SudokuResult Solve(int[] puzzle) { stopwatch.Stop(); - if (span.IsValidSudoku()) - { - return new SudokuResult(_workingCopy, true, _steps, stopwatch.Elapsed.TotalMicroseconds, null, null, "Full valid board"); - } - - return new SudokuResult(_workingCopy, false, _steps, stopwatch.Elapsed.TotalMicroseconds, null, null, "Full invalid board"); + return span.IsValidSudoku() + ? new SudokuResult(_workingCopy, true, _steps, stopwatch.Elapsed.TotalMicroseconds, null, null, "Full valid board") + : new SudokuResult(_workingCopy, false, _steps, stopwatch.Elapsed.TotalMicroseconds, null, null, "Full invalid board"); } if (_score > 64)