sln_2022_16
Copyright(c) Eric Mertens 2022
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2022/day/16

>>> :{
:main +
    "Valve AA has flow rate=0; tunnels lead to valves DD, II, BB\n\
    \Valve BB has flow rate=13; tunnels lead to valves CC, AA\n\
    \Valve CC has flow rate=2; tunnels lead to valves DD, BB\n\
    \Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE\n\
    \Valve EE has flow rate=3; tunnels lead to valves FF, DD\n\
    \Valve FF has flow rate=0; tunnels lead to valves EE, GG\n\
    \Valve GG has flow rate=0; tunnels lead to valves FF, HH\n\
    \Valve HH has flow rate=22; tunnel leads to valve GG\n\
    \Valve II has flow rate=0; tunnels lead to valves AA, JJ\n\
    \Valve JJ has flow rate=21; tunnel leads to valve II\n"
:}
1651
1707
Synopsis

Documentation

main :: IO () Source #

>>> :main
1820
2602

solve :: Edges -> Int -> IntMap Int Source #

Find the maximum water flow achievable from activating all possible combinations of valves.

data S Source #

Constructors

S !Int Edges !SmallSet !Int 

newtype Edges Source #

Constructors

Node [(Edges, SmallSet, Int, Int)] 

renumber :: [(String, Int, [String])] -> (Int, [(Int, Int, [Int])]) Source #

buildEdges :: Int -> IntMap [(Int, Int, Int)] -> Edges Source #

Replace all the string names with sequentially assigned Int names to speed up comparisons and enable the use of SmallSet

fw Source #

Arguments

:: [Int]

all vertices

-> IntMap (IntMap Int)

distances between a pair of vertices

-> IntMap (IntMap Int)

shortest distance between two vertices

Floyd-Warshall shortest paths