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 a579afa commit cd9f7aa
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Sudoku/Solver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,19 @@ private static (Candidates Row, Candidates Column, Candidates Box) GetSectionCan

var boxCandidates = new Candidates();

for (var y = 0; y < 9; y++)
for (var i = 0; i < 81; i++)
{
var y9 = (y << 3) + y;
var x = i % 9;

var y3 = y / 3 * 3;
var y = i / 9;

var boxY = y / 3 * 3;

for (var x = 0; x < 9; x++)
{
rowCandidates.Remove(y, puzzle[x + y9]);
rowCandidates.Remove(y, puzzle[i]);

columnCandidates.Remove(y, puzzle[y + (x << 3) + x]);
columnCandidates.Remove(x, puzzle[i]);

boxCandidates.Remove(y3 + x / 3, puzzle[x + y9]);
}
boxCandidates.Remove(boxY + x / 3, puzzle[i]);
}

return (rowCandidates, columnCandidates, boxCandidates);
Expand Down

0 comments on commit cd9f7aa

Please sign in to comment.