feat(sterni/aoc/2021): day 15 solution
Change-Id: Idca2ae2829a7ee9e856aa7fcdc716c3055051062 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4363 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
This commit is contained in:
parent
0357dd973b
commit
01f4212ca1
1 changed files with 35 additions and 0 deletions
|
@ -278,3 +278,38 @@ ElementRarityDiff ← {
|
||||||
|
|
||||||
•Out "Day 14.1: "∾•Fmt ElementRarityDiff 10
|
•Out "Day 14.1: "∾•Fmt ElementRarityDiff 10
|
||||||
•Out "Day 14.2: "∾•Fmt ElementRarityDiff 40
|
•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
|
||||||
|
|
Loading…
Reference in a new issue