Skip to content

Commit

Permalink
feat: full day 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Dec 7, 2024
1 parent 95b810f commit e8cf252
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
17 changes: 8 additions & 9 deletions src/aoc24.org
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,19 @@ to get more context. These definitions and imports are shared by the various puz
VI ← {
hinp ← (↕∘≢•HashMap○⥊⊢) inp ← >•Flines Input𝕩
g ← ⊑/○⥊⟜(↕≢)'^'= inp ⋄ r ← ⟨¯1, 0⟩‿⟨0, 1⟩‿⟨1, 0⟩‿⟨0, ¯1⟩
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@
Sym ← {𝕊m: s ← •HashMap˜⟨⟩
(s.Keys@) ⋈ s.Has {𝕊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
}
pos ← ⍷⊏⍉>Sym hinp
eins ← ≠pos
eins‿zwei ⇐ (≠pos) ⋈ +´{nm ← (hinp.Keys@) •HashMap hinp.Values@
𝕩nm.Set '#' ⋄ ⊢´Sym nm }¨ pos ← ⍷⊏⍉>⊑Sym hinp
}

VI 6
VI _is 6
#+end_src

#+RESULTS:
: 5444
: 5444 1946 ⟩

#+BEGIN_EXPORT html
<div style="text-align: center; font-size: 2em; padding: 20px 0;">
Expand Down
15 changes: 7 additions & 8 deletions src/bqn/aoc24.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ V _is 5
VI ← {
hinp ← (≢•HashMap⥊⊢) inp>•Flines Input𝕩
g⊑/(↕≢)'^'= inpr ← ⟨¯1, 0⟩‿⟨0, 1⟩‿⟨1, 0⟩‿⟨0, ¯1
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@
Sym ← {𝕊m: s•HashMap˜⟨⟩
(s.Keys@) s.Has {𝕊pd:
s.Set˜pd'#'={𝕊:d˜p+dr}‿{𝕊:p4|d+1} m.Get@ p+dr
}•_while_{𝕊𝕩: (m.Has⊑𝕩) ¬s.Has𝕩} g0
}
pos⍷⊏⍉>Sym hinp
einspos
einszwei ⇐ (pos) +´{nm ← (hinp.Keys@) •HashMap hinp.Values@
𝕩nm.Set '#'´Sym nm }¨ pos⍷⊏⍉>⊑Sym hinp
}

VI 6
VI _is 6

0 comments on commit e8cf252

Please sign in to comment.