🐛 Day 2: Fixed edge-case in part 2 with errors at end of Report

This commit is contained in:
LeMoonStar 2024-12-02 21:37:12 +01:00
parent e1e9051ccb
commit b2c8337177

View file

@ -21,7 +21,11 @@ impl Report {
}
if !Self::safe_comparison(self.0[i - 1], self.0[i], &mut direction) {
if tolerance > 0 && i + 1 < self.0.len() {
if tolerance > 0 {
if (i + 1 >= self.0.len()) {
return true;
}
tolerance -= 1;
if !Self::safe_comparison(self.0[i - 1], self.0[i + 1], &mut direction) {
skip = true;