2025 Day 11 Part 2
This commit is contained in:
parent
29b8991f5b
commit
e85a8dcff5
1 changed files with 87 additions and 17 deletions
106
2025/day11.ua
106
2025/day11.ua
|
|
@ -1,23 +1,93 @@
|
|||
~ "aoc.ua" ~ Lines
|
||||
|
||||
Lines &fras "input/day11.txt"
|
||||
≡◇(
|
||||
∩□ °$"_: _"
|
||||
)
|
||||
⊙≡◇(□ °/$"_ _")
|
||||
map
|
||||
|
||||
0
|
||||
{["you"]}
|
||||
⍢(⊃(⊢∘|↘1∘|⋅⊙∘)
|
||||
# Path Agenda' Count Edges
|
||||
≍"out"⊸◇⊢
|
||||
⨬(◡⊃(◇⊢|⋅⋅⋅∘)
|
||||
°□get
|
||||
≡⌟⍚⊂
|
||||
⊂
|
||||
| ⋅⊙⊃(+1∘|⋅∘)
|
||||
)
|
||||
| >0 ⧻
|
||||
⍚(
|
||||
°$"_: _"
|
||||
⊙(◇⋕₃₆°/$"_ _")
|
||||
⋕₃₆
|
||||
≡⌞⊂
|
||||
)
|
||||
⋅⊙◌
|
||||
⍆ /◇⊂
|
||||
Edges ←
|
||||
|
||||
# Queue ? Edges
|
||||
TopoSort ← (
|
||||
$Edges
|
||||
|
||||
°˜⊟ ⊸⍉
|
||||
◴▽¬⊸∊
|
||||
$Queue
|
||||
|
||||
⊙($Nodes[])
|
||||
|
||||
⍢( # Queue Nodes Edges
|
||||
°⊂
|
||||
# N Queue' Nodes Edges
|
||||
⊃(⊙∘|⊂⊙⋅∘)
|
||||
# N Queue' Nodes' Edges
|
||||
◡(
|
||||
⊕□ ⊸≡(≠⊙⊢) ⊙⋅⋅∘
|
||||
∩°□ ⊃(⍣⊡[]0|⍣⊡[]1)
|
||||
≡⊣
|
||||
)
|
||||
# Neighbors Edges' N Queue' Nodes' Edges
|
||||
⊓($Neighbors|$Edges|◌|$Queue|$Nodes|◌)
|
||||
◡(˜▽⟜(¬˜∊) ⊙≡⊣∘)
|
||||
⊙◌
|
||||
⊃($Queue ⊂⊙⋅∘|⋅⋅⋅∘|⋅∘)
|
||||
| >0⧻
|
||||
)
|
||||
|
||||
⋅⊙◌
|
||||
)
|
||||
|
||||
# Count ? Edges End Start
|
||||
Paths ← (
|
||||
⊓($Edges|$End|$Start)
|
||||
$Queue ⊸TopoSort
|
||||
|
||||
⍢(↘1|≠⊢⊙⋅∘)
|
||||
|
||||
# ⍢(↘¯1|≠⊣⊙⋅⋅∘)
|
||||
⊙⊙◌
|
||||
|
||||
⟜($Counts insert⊢⊙(1 []))
|
||||
↘1
|
||||
|
||||
⍢(°⊂
|
||||
# N Queue' Counts Edges
|
||||
◡(⊙⋅⋅∘
|
||||
▽⊸≡(=⊙⊢∘)
|
||||
≡⊣
|
||||
)
|
||||
$Neighbors
|
||||
|
||||
◡(⊙⋅⋅⊙
|
||||
/+≡⌟(⍣get0)
|
||||
)
|
||||
⊃(⋅⋅⋅∘|insert ⊃(⋅⋅∘|⊙⋅⋅⋅∘))
|
||||
| >0⧻
|
||||
)
|
||||
⋅⊙◌
|
||||
⍣˜get0
|
||||
)
|
||||
|
||||
Part₁ ← Paths⊙(∩⋕₃₆ "out" "you")
|
||||
|
||||
Without ← ▽⊸≡(≠⊙⊢∘)
|
||||
|
||||
Part₂ ← (
|
||||
⊃(
|
||||
| Paths ∧Without (◇⋕₃₆ {"out" "dac"}) ⊙(∩⋕₃₆ "fft" "svr")
|
||||
| Paths ∧Without (◇⋕₃₆ {"svr" "out"}) ⊙(∩⋕₃₆ "dac" "fft")
|
||||
| Paths ∧Without (◇⋕₃₆ {"fft" "svr"}) ⊙(∩⋕₃₆ "out" "dac")
|
||||
| Paths ∧Without (◇⋕₃₆ {"out" "fft"}) ⊙(∩⋕₃₆ "dac" "svr")
|
||||
| Paths ∧Without (◇⋕₃₆ {"svr" "out"}) ⊙(∩⋕₃₆ "fft" "dac")
|
||||
| Paths ∧Without (◇⋕₃₆ {"dac" "svr"}) ⊙(∩⋕₃₆ "out" "fft")
|
||||
)
|
||||
+⊓(××|××)
|
||||
)
|
||||
|
||||
Part₁ Edges
|
||||
Part₂ Edges
|
||||
|
|
|
|||
Loading…
Reference in a new issue