From c7eed012f3d2fa812a7a5abd63f943290ef56401 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 12 Jan 2025 22:06:33 +0100 Subject: cleanup --- 2016/src/day06.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/2016/src/day06.cpp b/2016/src/day06.cpp index 5bd0f93..32bf9cc 100644 --- a/2016/src/day06.cpp +++ b/2016/src/day06.cpp @@ -36,8 +36,10 @@ solve(const vector& lines) ++counts[line[col]]; } - part1 += max_element(counts.begin(), counts.end(), [](auto lhs, auto rhs) { return lhs.second < rhs.second; })->first; - part2 += min_element(counts.begin(), counts.end(), [](auto lhs, auto rhs) { return lhs.second < rhs.second; })->first; + const auto [min, max] = ranges::minmax_element(counts, [](auto lhs, auto rhs) { return lhs.second < rhs.second; }); + + part1 += max->first; + part2 += min->first; } cout << part1 << '\n' -- cgit v1.3