diff options
-rwxr-xr-x | users/sterni/exercises/aoc/2021/solutions.bqn | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/users/sterni/exercises/aoc/2021/solutions.bqn b/users/sterni/exercises/aoc/2021/solutions.bqn index 5a957fc132d6..45c19998bcf7 100755 --- a/users/sterni/exercises/aoc/2021/solutions.bqn +++ b/users/sterni/exercises/aoc/2021/solutions.bqn @@ -125,6 +125,26 @@ CO2ScrubberRating ← DebinList 0 >_lifeSupportRating ⊢ •Out "Day 3.2: "∾•Fmt (OxygenGeneratorRating×CO2ScrubberRating) day3Input # +# 2021-12-04 +# + +day4Numbers ← ReadDec¨ ',' SplitOn ⊑ReadInput 4 +day4Boards ← ReadDec¨>˘(' '⊸SplitOn¨)> (<⟨⟩) SplitOn 2↓ReadInput 4 + +BoardWins ← {C ← ∨´∘(∧´˘) ⋄ (C∨C∘⍉)𝕩} + +_CallNumber ← {(𝕗∊⥊𝕩) (∨⍟(¬∘BoardWins∘⊢))˘ 𝕨} + +BoardWinScores ← { + 𝕩 (0⊸</×) (⊢-») (+´)∘(BoardWins˘/(+´⥊)˘∘(𝕨⊸×⟜¬))¨ (<0⥊˜≢𝕨) (𝕨 _CallNumber)`𝕩 +} + +day4WinScores ← day4Boards BoardWinScores day4Numbers + +•Out "Day 4.1: "∾•Fmt ⊑day4WinScores +•Out "Day 4.2: "∾•Fmt ⊑⌽day4WinScores + +# # 2021-12-06 # |