Skip to content

Commit

Permalink
fix: correct part one and partial two of day 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 7, 2024
1 parent 4df8f7f commit 95b810f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
15 changes: 9 additions & 6 deletions src/aoc24.org
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,22 @@ to get more context. These definitions and imports are shared by the various puz

#+begin_src bqn :tangle ./bqn/aoc24.bqn
VI ← {
m ← (↕∘≢•HashMap○⥊⊢) inp ← >•Flines Input𝕩
hinp ← (↕∘≢•HashMap○⥊⊢) inp ← >•Flines Input𝕩
g ← ⊑/○⥊⟜(↕≢)'^'= inp ⋄ r ← ⟨¯1, 0⟩‿⟨0, 1⟩‿⟨1, 0⟩‿⟨0, ¯1⟩
s ← •HashMap˜⟨⟩
{𝕊p‿d: s.Set˜p‿d ⋄ '#'=◶{𝕊:d⋈˜p+d⊑r}‿{𝕊:p⋈4|d+1} m.Get⎊@ p+d⊑r
}•_while_{𝕊𝕩: (m.Has⊑𝕩) ∧ ¬s.Has𝕩} g‿0
s.Count@
Sym ← {𝕊m:
s ← •HashMap˜⟨⟩
{𝕊p‿d: s.Set˜p‿d ⋄ '#'=◶{𝕊:d⋈˜p+d⊑r}‿{𝕊:p⋈4|d+1} m.Get⎊@ p+d⊑r
}•_while_{𝕊𝕩: (m.Has⊑𝕩) ∧ ¬s.Has𝕩} g‿0 ⋄ s.Keys@
}
pos ← ⍷⊏⍉>Sym hinp
eins ← ≠pos
}

VI 6
#+end_src

#+RESULTS:
: 6204
: 5444

#+BEGIN_EXPORT html
<div style="text-align: center; font-size: 2em; padding: 20px 0;">
Expand Down
13 changes: 8 additions & 5 deletions src/bqn/aoc24.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ V ← {
V _is 5

VI ← {
m ← (≢•HashMap⥊⊢) inp>•Flines Input𝕩
hinp ← (≢•HashMap⥊⊢) inp>•Flines Input𝕩
g⊑/(↕≢)'^'= inpr ← ⟨¯1, 0⟩‿⟨0, 1⟩‿⟨1, 0⟩‿⟨0, ¯1
s•HashMap˜⟨⟩
{𝕊pd: s.Set˜pd'#'={𝕊:d˜p+dr}‿{𝕊:p4|d+1} m.Get@ p+dr
}•_while_{𝕊𝕩: (m.Has⊑𝕩) ¬s.Has𝕩} g0
s.Count@
Sym ← {𝕊m:
s•HashMap˜⟨⟩
{𝕊pd: s.Set˜pd'#'={𝕊:d˜p+dr}‿{𝕊:p4|d+1} m.Get@ p+dr
}•_while_{𝕊𝕩: (m.Has⊑𝕩) ¬s.Has𝕩} g0s.Keys@
}
pos⍷⊏⍉>Sym hinp
einspos
}

VI 6

0 comments on commit 95b810f

Please sign in to comment.