fixed crash

This commit is contained in:
Seth Samuel 2024-12-09 16:26:21 +13:00
parent 2a57da02a9
commit c172b4e1ef
8 changed files with 19 additions and 4 deletions

View file

@ -1,3 +1,6 @@
86 87 88 90 92 93 93 90
3 5 8 8 10 14
20 23 25 25 25
81 83 84 85 87
87 90 92 95 96 93
12 15 16 17 17
@ -9,9 +12,6 @@
60 63 65 63 65 69
70 73 76 79 77 78 84
25 27 29 32 35 35 36
86 87 88 90 92 93 93 90
20 23 25 25 25
3 5 8 8 10 14
3 4 7 9 12 12 14 20
72 75 79 80 82
5 7 11 14 15 18 15

View file

@ -19,6 +19,7 @@ int main(){
string line;
int safeReports = 0;
stringstream wholeDoc;
int linesReadFromFile= 0;
ifstream puzzle("input.txt", ifstream::in);
@ -30,6 +31,7 @@ int main(){
int number = stoi(numberString);
currentLevels.push_back(number);
}
linesReadFromFile++;
list<int> currentLevelsBackup = currentLevels;
int numOfLevelsProcessed = 0;
@ -91,6 +93,12 @@ int main(){
listDirty = true;
}
if(listDirty&&dir==DOWN&&levelGoesUp.size()>0){
currentLevels.clear();
} else if(listDirty&&dir==UP&&levelGoDown.size()>0){
currentLevels.clear();
}
if (!currentLevels.empty()){
if (dir==UP&&levelGoDown.size()==1){
list<int>::iterator itNumberToDelete = currentLevels.begin();
@ -125,6 +133,7 @@ int main(){
}
}
cout << safeReports;
cout <<"lines read in: " << linesReadFromFile<<"\n";
cout <<"safe Reports: " << safeReports;
puzzle.close();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.