From 311b69fcf28ab9c92123b792b97ba4569161dfb6 Mon Sep 17 00:00:00 2001 From: Panadestein Date: Wed, 4 Dec 2024 10:58:34 +0100 Subject: [PATCH] feat: added day 4. --- src/aoc24.org | 18 ++++++++++++++++-- src/bqn/aoc24.bqn | 12 ++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/aoc24.org b/src/aoc24.org index b3805cb..d1aa809 100644 --- a/src/aoc24.org +++ b/src/aoc24.org @@ -29,7 +29,7 @@ to get more context. Each day corresponds to a function, and the following top-l additional purpose of tracking my progress: #+begin_src bqn :tangle ./bqn/aoc24.bqn :results none - ⟨I, II, III⟩⇐ + ⟨I, II, III, IV⟩⇐ #+end_src These definitions and imports are shared by the various puzzles: @@ -78,7 +78,7 @@ These definitions and imports are shared by the various puzzles: #+begin_src bqn :tangle ./bqn/aoc24.bqn III ← { mem ← •FChars Input𝕩 - prg ← mem/˜1{·𝕊¯1:0;·𝕊1:1;𝕨𝕊0:𝕨}`-´"do()"‿"don't()"(≢∘⊢↑⍷)¨•FLines Input 𝕩 + t‿ts ← ⟨"XMAS"‿"SAMX", "MSAMS"‿"SMASM"‿"SSAMM"‿"MMASS"⟩ + eins ⇐ +´t(≢∘⊢↑⍷){+´⟨⥊+´𝕨𝔽¨<𝕩, ⥊+´𝕨𝔽¨<⍉𝕩, ∾+˝𝕨𝔽⌜𝔾𝕩, ∾+˝𝕨𝔽⌜𝔾⌽⍉𝕩⟩}((+⌜´↕¨∘≢)⊸⊔) inp + zwei ⇐ +´⥊{ts≡¨<(⌽˘⊸∨=⌜˜↕3)/○⥊𝕩}⎉2 3‿3↕inp + } + IV _is 4 +#+end_src + +#+RESULTS: +: ⟨ 2397 1824 ⟩ + ** V ** VI ** VII diff --git a/src/bqn/aoc24.bqn b/src/bqn/aoc24.bqn index 61898c5..48804bc 100644 --- a/src/bqn/aoc24.bqn +++ b/src/bqn/aoc24.bqn @@ -1,4 +1,4 @@ -⟨I, II, III⟩⇐ +⟨I, II, III, IV⟩⇐ Split ← (¬-˜⊢×·+`»⊸>)∘≠⊔⊢ Input ← {"../supp/aoc/2024/"∾".inp"∾˜•Fmt𝕩} @@ -22,7 +22,7 @@ II _is 2 III ← { mem ← •FChars Input𝕩 - prg ← mem/˜1{·𝕊¯1:0;·𝕊1:1;𝕨𝕊0:𝕨}`-´"do()"‿"don't()"(≢∘⊢↑⍷)¨•FLines Input 𝕩 + t‿ts ← ⟨"XMAS"‿"SAMX", "MSAMS"‿"SMASM"‿"SSAMM"‿"MMASS"⟩ + eins ⇐ +´t(≢∘⊢↑⍷){+´⟨⥊+´𝕨𝔽¨<𝕩, ⥊+´𝕨𝔽¨<⍉𝕩, ∾+˝𝕨𝔽⌜𝔾𝕩, ∾+˝𝕨𝔽⌜𝔾⌽⍉𝕩⟩}((+⌜´↕¨∘≢)⊸⊔) inp + zwei ⇐ +´⥊{ts≡¨<(⌽˘⊸∨=⌜˜↕3)/○⥊𝕩}⎉2 3‿3↕inp +} +IV _is 4