From 1478c47666dad55f159bc921ac1eda7778e3adc4 Mon Sep 17 00:00:00 2001 From: mtrx Date: Wed, 4 Dec 2024 23:18:44 +0100 Subject: [PATCH] woops mixed up 'and' and 'or' --- solutions/02.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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?