simpler
This commit is contained in:
parent
ebb068cfc5
commit
1b5607c8fe
11
day01.cpp
11
day01.cpp
|
@ -1,28 +1,21 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <numeric>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <aocpp/Startup.hpp>
|
#include <aocpp/Startup.hpp>
|
||||||
|
|
||||||
auto main(int argc, char** argv) -> int {
|
auto main(int argc, char** argv) -> int {
|
||||||
auto fin = aocpp::Startup(argc, argv);
|
auto fin = aocpp::Startup(argc, argv);
|
||||||
std::vector<std::int64_t> input;
|
|
||||||
std::copy(std::istream_iterator<std::int64_t>{fin},
|
|
||||||
std::istream_iterator<std::int64_t>{},
|
|
||||||
std::back_inserter(input));
|
|
||||||
|
|
||||||
auto fuel = [](std::int64_t& x) { return x=x/3-2; };
|
auto fuel = [](std::int64_t& x) { return x=x/3-2; };
|
||||||
|
|
||||||
|
std::int64_t x;
|
||||||
std::int64_t part1 = 0;
|
std::int64_t part1 = 0;
|
||||||
std::int64_t part2 = 0;
|
std::int64_t part2 = 0;
|
||||||
|
|
||||||
for (auto x : input) {
|
while (fin >> x) {
|
||||||
part1 += fuel(x);
|
part1 += fuel(x);
|
||||||
for (; x > 0; fuel(x)) {
|
for (; x > 0; fuel(x)) {
|
||||||
part2 += x;
|
part2 += x;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user