This commit is contained in:
nim-ka
2022-11-19 22:52:51 +00:00
parent 4ee438f8d6
commit 0485b4f035
74 changed files with 9130 additions and 44 deletions

View File

@@ -21,13 +21,13 @@ class SnailfishNumber {
return true
}
}
if (this.right instanceof SnailfishNumber) {
if (this.right.explode(depth + 1)) {
return true
}
}
if (!(this.left instanceof SnailfishNumber) && !(this.right instanceof SnailfishNumber) && depth >= 4) {
let lastNode = this
let node = this.parent
@@ -142,3 +142,7 @@ function day18(input, part2) {
return pairs.map((e) => e[0].add(e[1]).magnitude()).max()
}
}
if (typeof window == "undefined") {
module.exports = day18
}