From bdbf8a439ae66bae162df12a53cc2914ed6c3654 Mon Sep 17 00:00:00 2001 From: yut23 Date: Sat, 4 Jan 2025 14:52:53 -0500 Subject: [PATCH] 2024: fix includes with IWYU --- 2024/src/day22.hpp | 3 --- 2024/src/day23.cpp | 5 ++++- 2024/src/day23.hpp | 5 ++++- 2024/src/day24.hpp | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/2024/src/day22.hpp b/2024/src/day22.hpp index af3f32d..b7e34d5 100644 --- a/2024/src/day22.hpp +++ b/2024/src/day22.hpp @@ -8,9 +8,6 @@ #ifndef DAY22_HPP_A3Y597BB #define DAY22_HPP_A3Y597BB -#include // for istream -#include // for string, getline - namespace aoc::day22 { void xorshift(long &secret, int shift) { diff --git a/2024/src/day23.cpp b/2024/src/day23.cpp index a07985d..aa6acb7 100644 --- a/2024/src/day23.cpp +++ b/2024/src/day23.cpp @@ -15,10 +15,13 @@ int main(int argc, char **argv) { auto graph = aoc::day23::ComputerGraph::read(infile); + // part 1 ends up clearing the graph, so do part 2 first const auto password_parts = graph.find_password(); - // this modifies the graph, so do it second + + // part 1 std::cout << graph.count_t_triangles() << "\n"; + // output the password for part 2 for (auto it = password_parts.begin(); it != password_parts.end(); ++it) { if (it != password_parts.begin()) { std::cout << ","; diff --git a/2024/src/day23.hpp b/2024/src/day23.hpp index eb855d2..3b40ad8 100644 --- a/2024/src/day23.hpp +++ b/2024/src/day23.hpp @@ -10,10 +10,13 @@ #include "lib.hpp" // for DEBUG #include // for ranges::sort +#include // for operator<(string, string) +#include // for greater #include // for istream, cerr #include // for string #include // for unordered_map #include // for unordered_set +#include // for move, pair #include // for vector namespace aoc::day23 { @@ -133,7 +136,7 @@ std::vector ComputerGraph::find_password() const { std::vector password_parts(maximum_clique.begin(), maximum_clique.end()); - std::sort(password_parts.begin(), password_parts.end()); + std::ranges::sort(password_parts); return password_parts; } diff --git a/2024/src/day24.hpp b/2024/src/day24.hpp index eac358b..4074c57 100644 --- a/2024/src/day24.hpp +++ b/2024/src/day24.hpp @@ -14,11 +14,13 @@ #include // for assert #include // for size_t +#include // for hash (unordered_map, unordered_set) #include // for istream #include // for string, getline, to_string #include // for unordered_map #include // for unordered_set #include // for move +#include // for vector namespace aoc::day24 {