From 2db5c84bf8d08a6a5e832cba5c9b44081a4d1996 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Tue, 28 Mar 2023 16:49:04 -0700 Subject: [PATCH] 13: fancier boost index() --- 2022/13.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/2022/13.cpp b/2022/13.cpp index cde1d71..5f4499e 100644 --- a/2022/13.cpp +++ b/2022/13.cpp @@ -1,21 +1,19 @@ #include #include #include -#include #include -#include -#include #include +#include + +#include +#include +#include #include #include #include -#include -#include -#include - namespace { namespace phx = boost::phoenix; @@ -29,7 +27,6 @@ struct Tree { std::variant rep; }; - auto operator<(Tree const& x, std::int64_t y) -> bool; auto operator<(std::int64_t x, Tree const& y) -> bool; @@ -98,8 +95,8 @@ auto Parse(std::istream & in) -> Input auto Part1(Input const& input) -> std::size_t { std::int64_t result {0}; - for (auto const i : boost::irange(input.size())) { - if (input[i][0] < input[i][1]) { + for (auto const& [i,pair] : boost::adaptors::index(input)) { + if (pair[0] < pair[1]) { result += i + 1; } }