From 204bab640a08ff6c90c48970510186bc57b63105 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Tue, 1 Dec 2020 20:07:33 -0600 Subject: [PATCH] feat: complete part 2 of 2020-12-01 Advent of Code --- day_1/main.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/day_1/main.cpp b/day_1/main.cpp index b10147b..3c98604 100644 --- a/day_1/main.cpp +++ b/day_1/main.cpp @@ -2,10 +2,17 @@ #include #include +int part_1(); +int part_2(); + int main() { + part_1(); + part_2(); +} + +int part_1() { std::vector vector; std::ifstream input("../input.txt"); - std::string line; while(std::getline(input, line)) { @@ -17,9 +24,36 @@ int main() { for (int j : vector) { if (i + j == 2020) { std::cout << (i * j) << std::endl; + return 0; } } } - return 0; + return 1; } + + +int part_2() { + std::vector vector; + std::ifstream input("../input.txt"); + std::string line; + + while(std::getline(input, line)) { + int num = std::stoi(line); + vector.push_back(num); + } + + for (int i : vector) { + for (int j : vector) { + for (int k : vector) { + if (i + j + k == 2020) { + std::cout << (i * j * k) << std::endl; + return 0; + } + } + } + } + + return 1; +} +