Minor cleanup of day 24
parent
30bf0251bc
commit
aa924e801d
|
@ -151,8 +151,6 @@ int part2(const std::vector<std::vector<Direction>> &input) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next.clear();
|
|
||||||
|
|
||||||
for (auto &entry : flipped) {
|
for (auto &entry : flipped) {
|
||||||
auto neighbors = getNeighbors(entry.first);
|
auto neighbors = getNeighbors(entry.first);
|
||||||
int numFlippedNeighbors =
|
int numFlippedNeighbors =
|
||||||
|
@ -164,12 +162,11 @@ int part2(const std::vector<std::vector<Direction>> &input) {
|
||||||
bool nextState = entry.second;
|
bool nextState = entry.second;
|
||||||
if (entry.second && (numFlippedNeighbors == 0 || numFlippedNeighbors > 2)) {
|
if (entry.second && (numFlippedNeighbors == 0 || numFlippedNeighbors > 2)) {
|
||||||
nextState = false;
|
nextState = false;
|
||||||
next.emplace(entry.first, false);
|
|
||||||
} else if (!entry.second && numFlippedNeighbors == 2) {
|
} else if (!entry.second && numFlippedNeighbors == 2) {
|
||||||
nextState = true;
|
nextState = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
next.emplace(entry.first, nextState);
|
next[entry.first] = nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::swap(flipped, next);
|
std::swap(flipped, next);
|
||||||
|
|
Loading…
Reference in New Issue