|
|
|
@ -6,7 +6,8 @@ Result Day04::Task1() { |
|
|
|
|
|
|
|
|
|
for (const auto &[winning, having]: parseCards()) { |
|
|
|
|
std::set<uint8_t> result; |
|
|
|
|
std::set_intersection(winning.begin(), winning.end(), having.begin(), having.end(), std::inserter(result, result.begin())); |
|
|
|
|
std::set_intersection(winning.begin(), winning.end(), having.begin(), having.end(), |
|
|
|
|
std::inserter(result, result.begin())); |
|
|
|
|
if (!result.empty()) { |
|
|
|
|
sum += uint64(powl(2, result.size() - 1)); |
|
|
|
|
} |
|
|
|
@ -20,7 +21,8 @@ Result Day04::Task2() { |
|
|
|
|
|
|
|
|
|
for (const auto &[winning, having]: parseCards()) { |
|
|
|
|
std::set<uint8_t> result; |
|
|
|
|
std::set_intersection(winning.begin(), winning.end(), having.begin(), having.end(), std::inserter(result, result.begin())); |
|
|
|
|
std::set_intersection(winning.begin(), winning.end(), having.begin(), having.end(), |
|
|
|
|
std::inserter(result, result.begin())); |
|
|
|
|
matches.push_back(result.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|