Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehjohn committed Mar 21, 2024
1 parent cd9f7aa commit 70e018a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Sudoku/Solver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ private bool SolveStep(Span<int> puzzle, (Candidates Row, Candidates Column, Can

_moveType = MoveType.Guess;

FindHiddenSingles();
var single = FindHiddenSingles();

var move = FindLowestMove(puzzle);
var move = single == -1 ? FindLowestMove(puzzle) : ((single % 9, single / 9), _cellCandidates[single], 1);

return CreateNextSteps(puzzle, move, candidates);
}
Expand Down Expand Up @@ -201,7 +201,7 @@ private bool GetCellCandidates(Span<int> puzzle, (Candidates Row, Candidates Col
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void FindHiddenSingles()
private int FindHiddenSingles()
{
for (var yO = 0; yO < 81; yO += 27)
{
Expand Down Expand Up @@ -238,7 +238,7 @@ private void FindHiddenSingles()

_moveType = MoveType.HiddenSingle;

return;
return start + (y << 3) + y + x;
}
}
}
Expand Down Expand Up @@ -281,7 +281,7 @@ private void FindHiddenSingles()

_moveType = MoveType.HiddenSingle;

return;
return y9 + x;
}
}

Expand All @@ -294,10 +294,12 @@ private void FindHiddenSingles()

_moveType = MoveType.HiddenSingle;

return;
return (x << 3) + x + y;
}
}
}

return -1;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit 70e018a

Please sign in to comment.