13: fancier boost index()
This commit is contained in:
parent
ff7439a922
commit
2db5c84bf8
17
2022/13.cpp
17
2022/13.cpp
|
@ -1,21 +1,19 @@
|
|||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/phoenix.hpp>
|
||||
#include <boost/range/adaptor/indexed.hpp>
|
||||
|
||||
#include <doctest.h>
|
||||
|
||||
#include <aocpp/Startup.hpp>
|
||||
#include <aocpp/Overloaded.hpp>
|
||||
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/phoenix.hpp>
|
||||
#include <boost/range/irange.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
namespace phx = boost::phoenix;
|
||||
|
@ -29,7 +27,6 @@ struct Tree {
|
|||
std::variant<std::int64_t, Trees> 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user