}
Main←{
- names←{𝕩.name}¨𝕩
- flows←{𝕩.flow}¨𝕩
+ •Show names←{𝕩.name}¨𝕩
+ •Show flows←{𝕩.flow}¨𝕩
tunnelses←{names⊐⥊⋈˘𝕩.tunnels}¨𝕩
tunnels←{⊑𝕨∊𝕩⊑tunnelses}⌜˜↕≠𝕩
+ paths←{𝕩(⊢⌊⊏˘+⌜⊏)´↕≠𝕩}(tunnels⊏⟨∞,1⟩) # Stolen from BQNcrate
+ paths 0¨⌾(⋈˜¨∘↕∘≠⊸⊑) ↩ # Every valve zero distance from itself
+ •Show paths
+ •Show aa←⊑names⊐<"AA"
+ •Show nonzero←0<flows
Open←{1⌾(𝕩⊸⊑)𝕨}
Search←{
- 𝕊⟨0,·,·,·⟩: 0;
- 𝕊⟨time,·,vs,·⟩: ∧´vs? time×+´vs/flows;
- 𝕊⟨time,here,vs,visited⟩:
- #•Show ⟨time,here,vs,visited⟩
- time-↩1
- (+´vs/flows)+⌈´⟨Search⟨time,here,vs Open here,0¨visited⟩⟩∾{
- Search⟨time,𝕩,vs,visited Open here⟩
- }¨/(here⊏tunnels)∧¬visited
+ 𝕊⟨time,here,vs⟩:
+ # •Show ⟨time,here,vs⟩
+ ⌈´⟨0⟩∾{
+ Move⟨time-⟨here,𝕩⟩⊑paths+1,𝕩,vs⟩
+ }¨/nonzero∧¬vs
}
- Search⟨19,0,0¨𝕩,0¨𝕩⟩
+ Move←{
+ 𝕊⟨time,·,·⟩: time < 0 ? ¯∞;
+ 𝕊⟨time,here,vs⟩:
+ •Show ⟨time,here,vs⟩
+ •Show (time×here⊑flows) + Search⟨time,here,vs Open here⟩
+ }
+ Search⟨30,aa,0¨𝕩⟩
}
•Show Main Prep¨ •file.Lines ⊑•args