Compare commits

...

2 Commits

Author SHA1 Message Date
79ac732c39 emplace 2025-12-13 19:49:40 -10:00
2ce1b66855 emplace... why not? 2025-12-13 19:49:31 -10:00
2 changed files with 3 additions and 3 deletions

View File

@ -19,7 +19,7 @@ int main() {
char throwaway; char throwaway;
std::vector<Data> v; std::vector<Data> v;
while (file >> line.min >> throwaway >> line.max) { while (file >> line.min >> throwaway >> line.max) {
v.push_back(line); v.emplace_back(line);
file >> throwaway; file >> throwaway;
} }
std::cout << "Part 1: " << part_1(v) << std::endl; std::cout << "Part 1: " << part_1(v) << std::endl;
@ -67,7 +67,7 @@ int64_t part_2(const std::vector<Data> &v) {
} }
} }
// todo: dead code, delete me // todo: dead code, delete me, then inline solve_n
int64_t foobar = std::accumulate(v.begin(), v.end(), 0, [&ans](int64_t acc, Data d) { int64_t foobar = std::accumulate(v.begin(), v.end(), 0, [&ans](int64_t acc, Data d) {
for (auto n{d.min}; n <= d.max; ++n) { for (auto n{d.min}; n <= d.max; ++n) {
acc += solve_n(n); acc += solve_n(n);

View File

@ -12,7 +12,7 @@ int main() {
std::string line; std::string line;
std::vector<std::string> v; std::vector<std::string> v;
while (std::getline(file, line)) { while (std::getline(file, line)) {
v.push_back(line); v.emplace_back(line);
} }
std::cout << "Part 1: " << part_1(v) << std::endl; std::cout << "Part 1: " << part_1(v) << std::endl;
std::cout << "Part 2: " << part_2(v) << std::endl; std::cout << "Part 2: " << part_2(v) << std::endl;