Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehjohn committed Apr 8, 2024
1 parent 48d4148 commit 2e41b6a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
12 changes: 7 additions & 5 deletions src/Sudoku.Console/BulkSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -263,7 +265,7 @@ private void ShowProgress(int solved, bool noSummary)
Monitor.Exit(_consoleLock);
}

private static void DumpHistory(int[] puzzle, IReadOnlyList<Move> solution, HistoryType historyType)
private static void DumpHistory(int[] puzzle, IReadOnlyCollection<Move> solution, HistoryType historyType)
{
int yIncrement;

Expand Down
2 changes: 1 addition & 1 deletion src/Sudoku.Console/ConsoleApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private void GeneratePuzzles()
return;
}

if (clues < 17 || clues > 72)
if (clues is < 17 or > 72)
{
Out("\n Invalid input.");

Expand Down
14 changes: 7 additions & 7 deletions src/Sudoku.Console/ConsoleSolveVisualiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/Sudoku.Console/FileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}
}
9 changes: 3 additions & 6 deletions src/Sudoku/Solver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2e41b6a

Please sign in to comment.