Last active
June 16, 2017 16:00
-
-
Save rharriso/9288bd508f9a761ed1a8842e44f1beae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SudokuBoard { | |
void generateAllNeighbors () { | |
// generate row & col neighbors | |
for (int n = 0; n < 9; ++n) { | |
neighbors.insert({n, pos.j}); | |
neighbors.insert({pos.i, n}); | |
} | |
auto iFloor = (pos.i / 3) * THIRD; | |
auto jFloor = (pos.j / 3) * THIRD; | |
// generate cell neighbors | |
for (int n = iFloor; n < iFloor + 3; ++n) { | |
for (int m = jFloor; m < jFloor + 3; ++m) { | |
neighbors.insert({n, m}); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment