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

2025 Day 2 Part 2

This commit is contained in:
Jeremy Kaplan 2025-12-10 02:21:55 -05:00
commit e66deb148b

View file

@ -13,21 +13,58 @@ ParseRange ← (
) )
Seq ← + ⊙⇡ ⟜(+1-) Seq ← + ⊙⇡ ⟜(+1-)
Log ← ⌝˜ⁿ NumDigits ← ⧻⊥10
NumDigits ← +1 ⌊ Log10
RepeatDigits ← ( Chunks ← (
⊸(˜ⁿ10 ÷2NumDigits) ↯ 1_1
=⊃(⌊÷|◿) ⊙(⊥10)
) ⧈(⌝⊥10)
ValidId ← (
⊸(◿2 NumDigits)
⨬(¬RepeatDigits|1)
) )
⍚ParseRange Input Pattern ← (
≡( Chunks
♭Seq°⊂°□ =1⧻◴
▽¬ ⊸ValidId
/+
) )
/+
ValidIdWindow ← (
⊙(⊸NumDigits)
⤚(=0◿)
⨬(1⋅⋅|¬Pattern)
)
ValidId₁ ← (
⟜(⍤⤙≍ [] △)
⊸NumDigits
⊸(◿2)
⨬(ValidIdWindow÷2|1⋅⋅)
)
ValidId₂ ← (
⟜(⍤⤙≍ [] △)
⊸(+1 ⇡ ⌊÷2NumDigits)
≡ValidIdWindow
¬˜∊0
)
Part₁ ← (
⍚(
Seq°⊟
▽⊸≡(¬ValidId₁)
/+
)
/◇+
)
Part₂ ← (
⍚(
Seq°⊟
▽⊸≡(¬ValidId₂)
/+
)
/◇+
)
Ranges ← ⍚ParseRange Input
Part₁ Ranges
Part₂ Ranges