Make Grid iterable
This commit is contained in:
@@ -17,13 +17,13 @@ auto Part1(aocpp::Grid const &input, std::int64_t reps = 10'000) -> std::int64_t
|
||||
std::unordered_set<aocpp::Coord> infected;
|
||||
|
||||
// Initialize set of infected locations
|
||||
input.each([&infected](auto const pos, auto const cell)
|
||||
for (auto [pos, cell] : input)
|
||||
{
|
||||
if (cell == '#')
|
||||
{
|
||||
infected.insert(pos);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Start in the middle
|
||||
aocpp::Coord pos;
|
||||
@@ -62,13 +62,13 @@ auto Part2(aocpp::Grid const &input, std::int64_t reps = 10'000'000) -> std::int
|
||||
std::unordered_map<aocpp::Coord, char> cells;
|
||||
|
||||
// Initialize set of infected locations
|
||||
input.each([&cells](auto const pos, auto const cell)
|
||||
for (auto [pos, cell] : input)
|
||||
{
|
||||
if (cell == '#')
|
||||
{
|
||||
cells.try_emplace(pos, '#');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Start in the middle
|
||||
aocpp::Coord pos;
|
||||
|
Reference in New Issue
Block a user