diff options
author | sterni <sternenseemann@systemli.org> | 2021-12-26T19·47+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2021-12-26T19·51+0000 |
commit | d052bc59531a1139e357f598f6aaabdbb346634c (patch) | |
tree | 253457a5d06fdc2f1f5f232d69688365215d60c6 /users/sterni | |
parent | 675f97e5357ebad9a231834319dd6f098a1c1ddd (diff) |
feat(sterni/aoc/2021): day 4 solution r/3445
Change-Id: Ib8b4206b40acad32e10ebd9103e54074ba3452fc Reviewed-on: https://cl.tvl.fyi/c/depot/+/4681 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'users/sterni')
-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 # |