Skip to content

Commit

Permalink
feat: added day 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 4, 2024
1 parent c13255f commit 311b69f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/aoc24.org
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()"(≢∘⊢↑⍷)¨<mem
prg ← mem/˜1=×∘+`2×-´"do()"‿"don't()"(≢∘⊢↑⍷)¨<mem
mul‿cmd ← {(12↑↓⟜𝕩)¨4+/"mul("(≢∘⊢↑⍷)𝕩}¨mem‿prg
V ← {
l‿r←⊑⎊0¨1(↑⋈↓)','Split𝕩
Expand All @@ -93,6 +93,20 @@ These definitions and imports are shared by the various puzzles:
: ⟨ 165225049 108830766 ⟩

** IV

#+begin_src bqn :tangle ./bqn/aoc24.bqn
IV ← {
inp ← >•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
Expand Down
12 changes: 10 additions & 2 deletions src/bqn/aoc24.bqn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
I, II, III⟩⇐
I, II, III, IV⟩⇐

Split ← (¬-˜⊢×·+`»>)≠⊔⊢
Input ← {"../supp/aoc/2024/"".inp"˜•Fmt𝕩}
Expand All @@ -22,7 +22,7 @@ II _is 2

III ← {
mem•FChars Input𝕩
prgmem/˜1𝕊¯1:0𝕊1:1;𝕨𝕊0:𝕨}`-´"do()""don't()"(⊢↑⍷)¨<mem
prgmem/˜1+`2×-´"do()""don't()"(⊢↑⍷)¨<mem
mulcmd ← {(12↑↓𝕩)¨4+/"mul("(⊢↑⍷)𝕩}¨memprg
V ← {
lr0¨1(↑⋈↓)','Split𝕩
Expand All @@ -31,3 +31,11 @@ III ← {
einszwei ⇐ (+´V¨)¨ mulcmd
}
III _is 3

IV ← {
inp>•FLines Input 𝕩
tts ← ⟨"XMAS""SAMX", "MSAMS""SMASM""SSAMM""MMASS"
eins+´t(⊢↑⍷){+´⥊+´𝕨𝔽¨<𝕩, ⥊+´𝕨𝔽¨<⍉𝕩, ∾+˝𝕨𝔽𝔾𝕩, ∾+˝𝕨𝔽𝔾⌽⍉𝕩⟩}((+⌜´¨)) inp
zwei+´{ts¨<(˘∨=⌜˜3)/𝕩}2 33inp
}
IV _is 4

0 comments on commit 311b69f

Please sign in to comment.