mirror of
https://github.com/SebastianStork/advent-of-code.git
synced 2026-01-21 16:51:34 +01:00
Improve solutions for 2024 day 2 and 3
This commit is contained in:
parent
55e7f3c862
commit
1526a11a09
2 changed files with 37 additions and 20 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue