diff options
Diffstat (limited to 'users/sterni/exercises/aoc/2021')
-rwxr-xr-x | users/sterni/exercises/aoc/2021/solutions.bqn | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/users/sterni/exercises/aoc/2021/solutions.bqn b/users/sterni/exercises/aoc/2021/solutions.bqn index f240e7dc2d11..83949daa118b 100755 --- a/users/sterni/exercises/aoc/2021/solutions.bqn +++ b/users/sterni/exercises/aoc/2021/solutions.bqn @@ -278,3 +278,38 @@ ElementRarityDiff ← { •Out "Day 14.1: "∾•Fmt ElementRarityDiff 10 •Out "Day 14.2: "∾•Fmt ElementRarityDiff 40 + +# +# 2021-12-15 +# + +day15ExampleInput ← >⟨ + 1‿1‿6‿3‿7‿5‿1‿7‿4‿2 + 1‿3‿8‿1‿3‿7‿3‿6‿7‿2 + 2‿1‿3‿6‿5‿1‿1‿3‿2‿8 + 3‿6‿9‿4‿9‿3‿1‿5‿6‿9 + 7‿4‿6‿3‿4‿1‿7‿1‿1‿1 + 1‿3‿1‿9‿1‿2‿8‿1‿3‿7 + 1‿3‿5‿9‿9‿1‿2‿4‿2‿1 + 3‿1‿2‿5‿4‿2‿1‿6‿3‿9 + 1‿2‿9‿3‿1‿3‿8‿5‿2‿1 + 2‿3‿1‿1‿9‿4‿4‿5‿8‿1 +⟩ +day15Input ← '0'-˜ ((≠⋈≠∘⊑)⥊∾)ReadInput 15 + +LowestRiskLevel ← { + start ← 0˙⌾⊑ (⥊⟜∞) ≢𝕩 + ir ← (1⊑≢𝕩)⥊∞ + Step ← {𝕩 ⌊ 𝕨 + (ir⊸«⌊ir⊸»⌊∞⊸«˘⌊∞⊸»˘) 𝕩} + ⊑⌽⥊ 𝕩⊸Step _fix start +} + +! 40 = LowestRiskLevel day15ExampleInput + +•Out "Day 15.1: "∾•Fmt LowestRiskLevel day15Input + +FiveByFiveMap ← {(9⊸|)⌾(-⟜1) ∾(<𝕩)+ +⌜˜↕5} + +! 315 = LowestRiskLevel FiveByFiveMap day15ExampleInput + +•Out "Day 15.2: "∾•Fmt LowestRiskLevel FiveByFiveMap day15Input |