Skip to content

Commit

Permalink
feat: added slow day 14.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 15, 2024
1 parent 3b58cc1 commit e1849f1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
22 changes: 17 additions & 5 deletions src/aoc24.org
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ to get more context. These definitions and imports are shared by the various puz

#+begin_src bqn :tangle ./bqn/aoc24.bqn
Split ← (¬-˜⊢×·+`»⊸>)∘≠⊔⊢
Ints ← {•ParseFloat¨((¯1+⊢×·+`»⊸<)𝕩∊'0'+↕10)⊔𝕩}
SInts ← {•ParseFloat¨((¯1+⊢×·+`»⊸<)𝕩∊'-'∾'0'+↕10)⊔𝕩}
Input ← {"../supp/aoc/2024/"∾".inp"∾˜•Fmt𝕩}
_is ← {
∾⟨"Computed ", •Fmt(𝔽𝕩).eins, " and ",
Expand Down Expand Up @@ -285,18 +287,28 @@ powers of the adjacency matrix. This method is unfortunately slower than simple

#+begin_src bqn :tangle ./bqn/aoc24.bqn :exports both
XIII ← {
inp ← {𝕊p‿q‿pq:
e ← ∾{∾•Parsefloat⎊⟨⟩¨∾'+'Split¨','Split𝕩}¨ p‿q
3‿2⥊e∾∾•Parsefloat⎊⟨⟩¨∾'='Split¨','Split pq
}˘∘‿3⥊⟨⟩⊸≢¨⊸/•FLines Input 𝕩
∘‿3‿2⥊∾Ints¨⟨⟩⊸≢¨⊸/•FLines Input 𝕩
C ← (-´×⟜⌽˝){𝕨𝔽_𝕣[a,b,c]: (𝔽÷˜(𝕨+c)⌾⊏⋈○𝔽(𝕨+c)⌾(⊏⌽))a≍b}
eins‿zwei ⇐ {+´⥊3‿1×⎉1(∧´⌊⊸=)˘⊸/𝕩⊸C˘inp}¨ 0‿1e13
}
XIII _is 13
#+end_src

#+RESULTS:
: "Computed 32026 and 89013607072065 in 0.0044758065s"
: "Computed 480 and 875318608908 in 0.0003234552s"

#+begin_src bqn :tangle ./bqn/aoc24.bqn :exports both
XIV ← {
sm ← 0⥊˜s ← 101‿103 ⋄ inp ← 2‿2⊸⥊˘>SInts¨•FLines Input𝕩
Q ← {𝕊r: ×´+´∘⥊¨0‿2‿6‿8⊏⥊(({/𝕩∾1∾𝕩}·⌊÷⟜2)¨s)⊔+˝{1⌾((s|𝕨+r×𝕩)⊸⊑)sm}˝˘inp}
eins ⇐ Q 100
zwei ⇐ ⊑⍋Q¨↕1e5
}
XIV _is 14
#+end_src

#+RESULTS:
: "Computed 229069152 and 7383 in 52.1381874919s"

#+BEGIN_EXPORT html
<div style="text-align: center; font-size: 2em; padding: 20px 0;">
Expand Down
15 changes: 11 additions & 4 deletions src/bqn/aoc24.bqn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Split ← (¬-˜⊢×·+`»>)≠⊔⊢
Ints ← {•ParseFloat¨((¯1+⊢×·+`»<)𝕩'0'+↕10)𝕩}
SInts ← {•ParseFloat¨((¯1+⊢×·+`»<)𝕩'-''0'+↕10)𝕩}
Input ← {"../supp/aoc/2024/"".inp"˜•Fmt𝕩}
_is ← {
"Computed ", •Fmt(𝔽𝕩).eins, " and ",
Expand Down Expand Up @@ -141,11 +143,16 @@ XII ← {
XII _is 12

XIII ← {
inp ← {𝕊pqpq:
e{∾•Parsefloat⟨⟩¨'+'Split¨','Split𝕩}¨ pq
32e∾∾•Parsefloat⟨⟩¨'='Split¨','Split pq
}˘3⟨⟩¨/•FLines Input 𝕩
32⥊∾Ints¨⟨⟩¨/•FLines Input 𝕩
C ← (-´×˝){𝕨𝔽_𝕣[a,b,c]: (𝔽÷˜(𝕨+c)⊏⋈𝔽(𝕨+c)(⊏⌽))ab}
einszwei ⇐ {+´31×1(´=)˘/𝕩C˘inp}¨ 01e13
}
XIII _is 13

XIV ← {
sm0˜s101103inp22˘>SInts¨•FLines Input𝕩
Q ← {𝕊r: ×´+´¨0268⊏⥊(({/𝕩1𝕩⌊÷2)¨s)⊔+˝{1((s|𝕨+r×𝕩))sm}˝˘inp}
einsQ 100
zwei⊑⍋Q¨1e5
}
XIV _is 14

0 comments on commit e1849f1

Please sign in to comment.