diff --git a/2019/24.cpp b/2019/24.cpp index 4be6e90..ab8c3c7 100644 --- a/2019/24.cpp +++ b/2019/24.cpp @@ -33,7 +33,7 @@ struct Map { } }; -auto FindBugs(Map const& map) { +auto FindBugs(Map const& map) -> std::vector { std::vector result; std::int64_t w = map.rows[0].size(); @@ -82,12 +82,12 @@ struct Neighbor2 { } }; -template +template F> auto Step(std::vector const& bugs, F with_neighbors = F{}) { std::map adjacent; for (auto const& x : bugs) { - with_neighbors(x, [&adjacent](C n) -> void { adjacent[n]++; }); + with_neighbors(x, [&adjacent](C const& n) -> void { adjacent[n]++; }); } std::vector result; @@ -120,18 +120,18 @@ auto Part1(std::vector const& bugs) -> std::uint32_t { std::set seen; std::uint32_t bio; while (seen.insert(bio = Bio(cursor)).second) { - cursor = Step(cursor); + cursor = Step(cursor); } return bio; } auto Part2(std::vector const& bugs) { - std::vector> bugs2; + std::vector bugs2; for (auto const& [x,y] : bugs) { bugs2.push_back({{x-2,y-2},0}); } for (int i = 0; i < 200; i++) { - bugs2 = Step(bugs2); + bugs2 = Step(bugs2); } return bugs2.size(); }