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; +} +