Improve solutions for 2024 day 2 and 3

This commit is contained in:
SebastianStork 2024-12-11 23:16:12 +01:00
parent 55e7f3c862
commit 1526a11a09
2 changed files with 37 additions and 20 deletions

View file

@ -4,8 +4,9 @@
using namespace std;
void readInput(vector<vector<int>> &list)
vector<vector<int>> readInput()
{
vector<vector<int>> list;
string line;
while (getline(cin, line)) {
list.push_back({});
@ -15,6 +16,7 @@ void readInput(vector<vector<int>> &list)
list.back().push_back(value);
}
}
return list;
}
int getIndexOfUnsafeValue(const vector<int> &report)
@ -67,8 +69,7 @@ int calculateNumberOfSafeReports(const vector<vector<int>> &list, const bool app
int main()
{
vector<vector<int>> list;
readInput(list);
vector<vector<int>> list = readInput();
// Part one
cout << "Number of safe reports: " << calculateNumberOfSafeReports(list, false) << endl;