2022-11-06 21:12:30 -08:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iterator>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <aocpp/Startup.hpp>
|
|
|
|
|
|
|
|
auto main(int argc, char** argv) -> int {
|
2022-11-07 21:00:14 -08:00
|
|
|
auto& in = aocpp::Startup(argc, argv);
|
2022-11-06 21:12:30 -08:00
|
|
|
auto fuel = [](std::int64_t& x) { return x=x/3-2; };
|
|
|
|
|
2022-11-06 22:18:49 -08:00
|
|
|
std::int64_t x;
|
2022-11-06 21:12:30 -08:00
|
|
|
std::int64_t part1 = 0;
|
|
|
|
std::int64_t part2 = 0;
|
|
|
|
|
2022-11-07 21:00:14 -08:00
|
|
|
while (in >> x) {
|
2022-11-06 21:12:30 -08:00
|
|
|
part1 += fuel(x);
|
|
|
|
for (; x > 0; fuel(x)) {
|
|
|
|
part2 += x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::cout << "Part 1: " << part1 << std::endl;
|
|
|
|
std::cout << "Part 2: " << part2 << std::endl;
|
|
|
|
}
|