Skip to content

Commit

Permalink
feat: full day 9.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 9, 2024
1 parent b3d50cd commit 5ad233f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/aoc24.org
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ to get more context. These definitions and imports are shared by the various puz
VIII ← {
n ← ≠⊑inp‿ant ← (⊢⋈1↓⍷∘⥊)>•FLines Input𝕩
_tcd ← {(𝕨⊸×-(𝕨-1)×⊣)⌜˜⊸𝔽/○⥊⟜(↕≢)𝕩}
eins ⇐ (∧´≥⟜0∧<⟜n)¨⍷∾ 2 (⥊∘⊣/˜·¬⥊⊸∊)_tcd¨ ant=<inp
eins ⇐ ≠⍷(∧´≥⟜0∧<⟜n)⊸/∾ 2 (⥊∘⊣/˜·¬⥊⊸∊)_tcd¨ ant=<inp
zwei ⇐ +´(∧´≥⟜0∧<⟜n)¨⍷∾∾ (↕n) ⥊∘⊣_tcd¨⌜<ant=<inp
}
VIII _is 8
Expand All @@ -164,6 +164,24 @@ to get more context. These definitions and imports are shared by the various puz
#+RESULTS:
: ⟨ 291 1015 ⟩

** IX

#+begin_src bqn :tangle ./bqn/aoc24.bqn
IX ← {
f‿s ← <˘⍉↑‿2⥊•ParseFloat∘⋈¨ ⊑•FLines Input𝕩
m ← ¯1=d ← ∾⥊⍉ds ← (⊔˜/f)≍¯1¨∘↕¨s
ds ⊣ {n𝕊cf: (p<n)∧(≠f)>p←⊑1⊐˜(≠cf)≤+´¨¯1=1⊸⊏ds?
ds↩{cf«𝕩}⌾(1‿p⊸⊑){¯1¨𝕩}⌾(0‿n⊸⊑)ds⋄@
;@}´˘(⊢≍˘˜·⌽⊒˜)⌽⊏ds
eins ⇐ {+´/(𝕩-˜≠d)↑(d׬m)+(𝕩↑⌽/f)⌾(m⊸/)m}+´s
zwei ⇐ +´/(⊢ׯ1⊸≠)∾⥊⍉{𝕊⟨⟩:𝕩;(⌽∘⊣∾⊢)´𝕩⊔˜𝕩=¯1}¨⌾(1⊸⊏)ds
}
IX _is 9
#+end_src

#+RESULTS:
: ⟨ 6378826667552 6413328569890 ⟩

#+BEGIN_EXPORT html
<div style="text-align: center; font-size: 2em; padding: 20px 0;">
<a href="https://panadestein.github.io/blog/" style="text-decoration: none;">⊑∘∞</a>
Expand Down
13 changes: 12 additions & 1 deletion src/bqn/aoc24.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,18 @@ VII _is 7
VIII ← {
n≠⊑inpant ← (⊢⋈1↓⍷)>•FLines Input𝕩
_tcd ← {(𝕨×-(𝕨-1)×⊣)⌜˜𝔽/(↕≢)𝕩}
eins+´(´0∧<n)¨ 2 (⊣/˜·¬⥊)_tcd¨ ant=<inp
eins≠⍷(´0∧<n)/ 2 (⊣/˜·¬⥊)_tcd¨ ant=<inp
zwei+´(´0∧<n)¨⍷∾∾ (n) _tcd¨⌜<ant=<inp
}
VIII _is 8

IX ← {
fs<˘⍉↑2⥊•ParseFloat¨ ⊑•FLines Input𝕩
m¯1=d∾⥊⍉ds ← (˜/f)¯1¨¨s
ds {n𝕊cf: (p<n)(f)>p1˜(cf)≤+´¨¯1=1ds?
ds↩{cf«𝕩}(1p){¯1¨𝕩}(0n)ds⋄@
;@}´˘(⊢≍˘˜·⌽⊒˜)⌽⊏ds
eins ⇐ {+´/(𝕩-˜d)(d׬m)+(𝕩↑⌽/f)(m/)m}+´s
zwei+´/(⊢ׯ1)∾⥊⍉{𝕊⟨⟩:𝕩;(⊣∾⊢)´𝕩˜𝕩=¯1}¨(1)ds
}
IX _is 9

0 comments on commit 5ad233f

Please sign in to comment.