From ce8a6a1c795aec1b8483dcc6c1c13f094cd9e41c Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 11 Nov 2022 15:10:56 -0800 Subject: [PATCH] Update 24.cpp --- 2019/24.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/2019/24.cpp b/2019/24.cpp index f6eddf5..aac02d9 100644 --- a/2019/24.cpp +++ b/2019/24.cpp @@ -112,7 +112,7 @@ auto Neighbor2(std::pair cd) { } template -auto Step(std::set const& bugs, F const& neighbors) +auto Step(std::set const& bugs, F neighbors) { std::map adjacent; for (auto const& x : bugs) { @@ -132,7 +132,7 @@ auto Step(std::set const& bugs, F const& neighbors) return result; } -auto Bio(std::set const& bugs) { +auto Bio(std::set const& bugs) -> std::uint32_t { std::uint32_t result = 0; for (auto const& c : bugs) { result |= 1U << (5 * c.y + c.x); @@ -140,15 +140,14 @@ auto Bio(std::set const& bugs) { return result; } -auto Part1(std::set const& bugs) { - std::int64_t n = 0; +auto Part1(std::set const& bugs) -> std::uint32_t { auto cursor = bugs; std::set seen; - while (seen.insert(Bio(cursor)).second) { - n++; + std::uint32_t bio; + while (seen.insert(bio = Bio(cursor)).second) { cursor = Step(cursor, Neighbor1); } - return Bio(cursor); + return bio; } auto Part2(std::set const& bugs) {