Skip to content

Commit

Permalink
feat: added half baked 21.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 22, 2024
1 parent 69451b4 commit 5747878
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/aoc24.org
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,30 @@ At the end, we have identified all tiles that are part of at least one best path
#+end_src

#+RESULTS:
: "Computed 1463 and 985332 in 2.8664751945s"
: "Computed 1463 and 985332 in 2.9748486369s"

** XXI

#+begin_src bqn :tangle ./bqn/aoc24.bqn :exports both
XXI ← {
inp ← 3⊸↑¨•FLines Input𝕩
kbs ← ["789","456","123"," 0A"]‿[" ^A","<v>"] ⋄ dp ← •HashMap˜⟨⟩
F ← {
𝕊s‿k‿r: k>r ? ≠s; dp.Has 𝕩 ? dp.Get 𝕩;
𝕊s‿k‿r:
𝕩{𝕩⊣𝕨dp.Set𝕩}⊑+˝{
p‿q‿nl ← (𝕩∾' ')(⊑=/○⥊·↕∘≢⊢)¨<kbs⊑˜k>0
ns ← {0<+´×⟜⌽˝q‿p>∘=nl?⌽𝕩;𝕩}"<v^>"/˜0⌈∾¯1‿1⊸ר⋈⟜⌽q-p
F⟨ns∾'A', k+1, r⟩
}˘2↕'A'∾s
}
eins‿zwei ⇐ 2‿25 {+´𝕨{(•ParseFloat𝕩)×F𝕩‿0‿𝕨}¨𝕩}⌜ <inp
}
XXI _is 21
#+end_src

#+RESULTS:
: "Computed 195224 and 308034893632420 in 0.0011020566s"

#+BEGIN_EXPORT html
<div style="text-align: center; font-size: 2em; padding: 20px 0;">
Expand Down
16 changes: 16 additions & 0 deletions src/bqn/aoc24.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,19 @@ XX ← {
einszwei+´¨mh=2, mh20⟩{100𝕨×𝕩}¨<diff
}
XX _is 20

XXI ← {
inp3¨•FLines Input𝕩
kbs ← ["789","456","123"," 0A"]‿[" ^A","<v>"] ⋄ dp•HashMap˜⟨⟩
F ← {
𝕊skr: k>r ? s; dp.Has 𝕩 ? dp.Get 𝕩;
𝕊skr:
𝕩{𝕩𝕨dp.Set𝕩}⊑+˝{
pqnl ← (𝕩' ')(⊑=/·≢⊢)¨<kbs˜k>0
ns ← {0<+´×˝qp>=nl?𝕩;𝕩}"<v^>"/˜0⌈∾¯11רq-p
Fns'A', k+1, r
}˘2'A's
}
einszwei225 {+´𝕨{(•ParseFloat𝕩)×F𝕩0𝕨}¨𝕩} <inp
}
XXI _is 21

0 comments on commit 5747878

Please sign in to comment.