aoc24: day01 update to zip

Include Linux command stuff to use clang compiler.
This commit is contained in:
2024-12-02 14:41:42 +01:00
parent 04e64612b9
commit 94d3ffe921
2 changed files with 11 additions and 4 deletions

View File

@@ -48,11 +48,12 @@ auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int {
std::sort(std::begin(a), std::end(a));
std::sort(std::begin(b), std::end(b));
auto diff_view = std::views::zip_transform([](auto a, auto b) {
return a > b ? a - b : b - a;
}, a, b);
auto diff_view = std::views::zip(a, b) | std::views::transform([](auto const& p) {
auto const [x, y] = p;
return x > y ? x - y : y - x;
});
auto const sum = std::accumulate(std::begin(diff_view), std::end(diff_view), 0);
fmt::print("Part A: {}\n", std::abs(sum));
auto values = a | std::views::transform([&b](auto v) {