diff --git a/Day8/Day8A.cpp b/Day8/Day8A.cpp index f03e994..fc621f3 100644 --- a/Day8/Day8A.cpp +++ b/Day8/Day8A.cpp @@ -7,9 +7,8 @@ std::vector read_input() input.reserve(20000); int i = 0; - while (std::cin >> i) { + while (std::cin >> i) input.push_back(i); - } return input; } @@ -20,13 +19,11 @@ int read_node(std::vector::iterator &it) int meta_count = *it++; int value = 0; - for (int i = 0; i < child_count; i++) { + for (int i = 0; i < child_count; i++) value += read_node(it); - } - for (int i = 0; i < meta_count; i++) { + for (int i = 0; i < meta_count; i++) value += *it++; - } return value; } diff --git a/Day8/Day8B.cpp b/Day8/Day8B.cpp index b87caf1..0036b05 100644 --- a/Day8/Day8B.cpp +++ b/Day8/Day8B.cpp @@ -27,9 +27,8 @@ int read_node(std::vector::iterator &it) } std::vector children; - for (int i = 0; i < child_count; i++) { + for (int i = 0; i < child_count; i++) children.push_back(read_node(it)); - } for (int i = 0; i < meta_count; i++) { int index = *it++;