diff --git a/solutions/02.ts b/solutions/02.ts index bdeaa01..e7c60a8 100644 --- a/solutions/02.ts +++ b/solutions/02.ts @@ -14,7 +14,7 @@ class DayTwo implements Solvable { while (j < levels.length) { // is unsafe if ascent / descend bigger than 3 or smaller than 1 const diff = Math.abs(levels[i] - levels[j]) - if (diff > 3 && diff < 1) { + if (diff > 3 || diff < 1) { return false } // calculate positive or negative gradient @@ -22,10 +22,7 @@ class DayTwo implements Solvable { gradients.push("ascending") } else if (levels[i] > levels[j]) { gradients.push("descending") - } else { - return false - } - i++ + } i++ j++ } // is safe and constant gradient?