Watch
1
0
Fork
You've already forked advent-of-code
0

2025 Day 1 Part 2

This commit is contained in:
Jeremy Kaplan 2025-12-08 01:56:00 -06:00
commit af03b8491b

View file

@ -2,9 +2,38 @@
Input ← Lines &fras "input/day01.txt" Input ← Lines &fras "input/day01.txt"
Dirs ← ≡°□ +⊃(¯=@L) (=@R) ⍚⊢ Input Dirs ← ≡°□ +⊃(¯=@L) (=@R) ⍚⊢
Amts ← ⋕⍚(↘ 1) Input Amts ← ⋕⍚(↘ 1)
Ops ← × ⊃Dirs Amts
× Dirs Amts Part₁ ← (
⬚50\(◿100 +) ⬚50\(◿100 +)
/+ =0 /+ =0
)
Div ← ⌊⌵÷
Rem ← ×⊃(◿⊙⌵|±⋅)
DivRem ← ⊂ ⊃(Div|Rem)
ChSgn ← ≠∩±
NeitherZero ← |2 =0 +∩(=0)
CrossedZero ← |2 ×⊃(NeitherZero|ChSgn)
TouchedZero ← |2 × ≠0 ⊙(=0)
Update ← |2 Rem100 + Rem100 # op pos
Z₁ ← |2 Div100 ⊙◌ # op [pos]
Z₂ ← |2 Div100 +Rem100 # op pos
Z₃ ← |2 TouchedZero ⟜+Rem100 # op pos
Z₄ ← |2 CrossedZero ⟜+Rem100 # op pos
Part₂ ← (
⬚[0 50] /(|2
⊃(⊡0|⊡1)
⊙(⊂⊂⊂ ⊃(Z₁|Z₂|Z₃|Z₄|Update))
˜∧+
)
)
Part₁ Ops Input
Part₂ Ops Input