woops mixed up 'and' and 'or'
This commit is contained in:
parent
ccf3e827a9
commit
1478c47666
1 changed files with 2 additions and 5 deletions
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue