Last active
April 30, 2017 22:54
-
-
Save rharriso/76ffe4556bb1c82507f3a4cf4ffff039 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
bool fillCells() { | |
for(auto cell : this->cells()) { | |
// get first cell and tail | |
auto cell = remainingCells.front(); | |
remainingCells.pop_front(); | |
set<int> neighborValues = {}; | |
for(auto &neighbor : cell->neighbors) { | |
auto value = this->at(neighbor)->value; | |
neighborValues.insert(value); | |
} | |
vector<int> options; | |
set_difference(VALID_VALUES.begin(), VALID_VALUES.end(), | |
neighborValues.begin(), neighborValues.end(), | |
inserter(options, options.begin()) | |
); | |
random_shuffle(options.begin(), options.end()); | |
cell->value = options[0]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment