Compare commits
No commits in common. '68ce9ca70394fcbbf2a80f14ddee6188ef3840fa' and 'adf256572957c38fba3b359108437aa1b3205bd1' have entirely different histories.
68ce9ca703
...
adf2565729
6 changed files with 8 additions and 29 deletions
@ -1,24 +1,9 @@ |
||||
#include "Day01.h" |
||||
|
||||
Result Day01::Task1() { |
||||
subSums.push_back(0); |
||||
for (const std::string& line : input){ |
||||
if (line.empty()) |
||||
subSums.push_back(0); |
||||
else |
||||
subSums[subSums.size() - 1] += stoi(line); |
||||
} |
||||
return to_string(*std::max_element(subSums.begin(), subSums.end())); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day01::Task2() { |
||||
std::sort(subSums.begin(), subSums.end()); |
||||
|
||||
int sum = 0; |
||||
for (int i = 0; i < 3; i++){ |
||||
sum += subSums.back(); |
||||
subSums.pop_back(); |
||||
} |
||||
|
||||
return to_string(sum); |
||||
return Day::Task2(); |
||||
} |
Loading…
Reference in new issue