2025 Day 11 Part 2
This commit is contained in:
parent
29b8991f5b
commit
e85a8dcff5
1 changed files with 87 additions and 17 deletions
100
2025/day11.ua
100
2025/day11.ua
|
|
@ -1,23 +1,93 @@
|
||||||
~ "aoc.ua" ~ Lines
|
~ "aoc.ua" ~ Lines
|
||||||
|
|
||||||
Lines &fras "input/day11.txt"
|
Lines &fras "input/day11.txt"
|
||||||
≡◇(
|
|
||||||
∩□ °$"_: _"
|
|
||||||
)
|
|
||||||
⊙≡◇(□ °/$"_ _")
|
|
||||||
map
|
|
||||||
|
|
||||||
0
|
⍚(
|
||||||
{["you"]}
|
°$"_: _"
|
||||||
⍢(⊃(⊢∘|↘1∘|⋅⊙∘)
|
⊙(◇⋕₃₆°/$"_ _")
|
||||||
# Path Agenda' Count Edges
|
⋕₃₆
|
||||||
≍"out"⊸◇⊢
|
≡⌞⊂
|
||||||
⨬(◡⊃(◇⊢|⋅⋅⋅∘)
|
|
||||||
°□get
|
|
||||||
≡⌟⍚⊂
|
|
||||||
⊂
|
|
||||||
| ⋅⊙⊃(+1∘|⋅∘)
|
|
||||||
)
|
)
|
||||||
|
⍆ /◇⊂
|
||||||
|
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⧻
|
| >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