Skip to content

Commit

Permalink
Generating Boards 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rharriso committed Nov 3, 2018
1 parent f187f16 commit 2873393
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ class SudokuCell {
neighbors.insert({pos.i, n});
}

// find the block top left coordinate
auto iFloor = (pos.i / THIRD) * THIRD;
auto jFloor = (pos.j / THIRD) * THIRD;

// generate cell neighbors
// generate block neighbors
for (int n = iFloor; n < iFloor + THIRD ; ++n) {
for (int m = jFloor; m < jFloor + THIRD; ++m) {
neighbors.insert({n, m});
Expand All @@ -79,7 +80,7 @@ class SudokuCell {
auto iFloor = (pos.i / THIRD) * THIRD;
auto jFloor = (pos.j / THIRD) * THIRD;

// generate cell neighbors
// generate block neighbors
for (int i = iFloor; i <= pos.i ; ++i) {
for (int j = jFloor; (i < pos.i && j < jFloor + THIRD) || j < pos.j ; ++j) {
neighbors.insert({i, j});
Expand Down

0 comments on commit 2873393

Please sign in to comment.