diff --git a/day01.cpp b/day01.cpp index 624630d..c1131ac 100644 --- a/day01.cpp +++ b/day01.cpp @@ -1,28 +1,21 @@ #include -#include -#include #include #include #include #include #include -#include #include auto main(int argc, char** argv) -> int { auto fin = aocpp::Startup(argc, argv); - std::vector input; - std::copy(std::istream_iterator{fin}, - std::istream_iterator{}, - std::back_inserter(input)); - auto fuel = [](std::int64_t& x) { return x=x/3-2; }; + std::int64_t x; std::int64_t part1 = 0; std::int64_t part2 = 0; - for (auto x : input) { + while (fin >> x) { part1 += fuel(x); for (; x > 0; fuel(x)) { part2 += x;