Skip to content

Commit

Permalink
feat: better 18.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 19, 2024
1 parent 2654cb2 commit 5463457
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/aoc24.org
Original file line number Diff line number Diff line change
Expand Up @@ -470,18 +470,20 @@ At the end, we have identified all tiles that are part of at least one best path

#+begin_src bqn :tangle ./bqn/aoc24.bqn :exports both
XVIII ← {
n‿inf ← 70⋈1e9 ⋄ inp ← >⟨⟩⊸Ints¨•FLines Input𝕩
n ← 70 ⋄ inp ← >⟨⟩⊸Ints¨•FLines Input𝕩
g ← 1⌾⊑0¨ b ← (1⥊˜1+n‿n) {0⌾(𝕨⊸⊑)𝕩}´<˘1024↑inp
_sym ← {M _𝕣𝕩: ⊑{(𝕨+1)⋈m∧∨´⊢_cnu⊸∾<𝕩}´•_while_{𝕊c‿g: (c<inf)∧¬⊢´⊢˝g} 0‿𝕩}
_bs ← {Fs _𝕣 l‿r: ⊑{𝕊l‿r: m ← l+⌊2÷˜r-l ⋄ ⟨l‿m,m‿r⟩⊑˜Fs m}_fp𝕩}
_sym ← {M _𝕣𝕩: ⊑{(𝕨+1)⋈m∧∨´⊢_cnu⊸∾<𝕩}´•_while_{𝕊: ¬⊢´⊢˝⊢´𝕩} 0‿𝕩}
_symv ← {M _𝕣𝕩: 1=⊢´⊢˝{m∧∨´⊢_cnu⊸∾<𝕩}_fp𝕩}
eins ⇐ b _sym g
zwei ⇐ inp⊏˜{𝕊𝕩: p←inp⊏˜𝕩+1024 ⋄ inf > (b 0⌾(p⊸⊑)↩) _sym g}_bs 0⋈1024-˜≠inp
zwei ⇐ inp⊏˜⊑{
m ← ⌊𝕨+2÷˜𝕩-𝕨 ⋄ ⟨𝕨‿m,m‿𝕩⟩⊑˜{b 0⌾((𝕩⊏inp)⊸⊑)↩ ⋄ b _symv g}m
}´_fp 1025⋈≠inp
}
XVIII _is 18
#+end_src

#+RESULTS:
: "Computed 248 and ⟨ 17 45 ⟩ in 0.0035222522s"
: "Computed 248 and ⟨ 29 40 ⟩ in 0.0036658128s"

#+BEGIN_EXPORT html
<div style="text-align: center; font-size: 2em; padding: 20px 0;">
Expand Down
10 changes: 6 additions & 4 deletions src/bqn/aoc24.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ XVII ← {
XVII _is 17

XVIII ← {
ninf701e9inp>⟨⟩Ints¨•FLines Input𝕩
n70inp>⟨⟩Ints¨•FLines Input𝕩
g10¨ b ← (1˜1+nn) {0(𝕨)𝕩}´<˘1024inp
_sym ← {M _𝕣𝕩: {(𝕨+1)m∧∨´_cnu∾<𝕩}´_while_{𝕊cg: (c<inf)¬⊢´˝g} 0𝕩}
_bs ← {Fs _𝕣 lr: {𝕊lr: ml+⌊2÷˜r-l ⋄ ⟨lm,mr˜Fs m}_fp𝕩}
_sym ← {M _𝕣𝕩: {(𝕨+1)m∧∨´_cnu∾<𝕩}´_while_{𝕊: ¬⊢´˝´𝕩} 0𝕩}
_symv ← {M _𝕣𝕩: 1=⊢´˝{m∧∨´_cnu∾<𝕩}_fp𝕩}
einsb _sym g
zweiinp˜{𝕊𝕩: pinp˜𝕩+1024inf > (b 0(p)↩) _sym g}_bs 01024-˜inp
zweiinp˜{
m𝕨+2÷˜𝕩-𝕨 ⋄ ⟨𝕨m,m𝕩˜{b 0((𝕩inp))↩ ⋄ b _symv g}m
}´_fp 1025⋈≠inp
}
XVIII _is 18

0 comments on commit 5463457

Please sign in to comment.