woops mixed up 'and' and 'or'

This commit is contained in:
mtrx 2024-12-04 23:18:44 +01:00
parent ccf3e827a9
commit 1478c47666

View file

@ -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?