14 lines
479 B
Haskell
14 lines
479 B
Haskell
module Part1 where
|
|
|
|
import Commons
|
|
import Data.HashMap.Strict ((!))
|
|
|
|
|
|
getDistance :: String -> String -> [Instruction] -> Network -> Int
|
|
getDistance start end [] network = getDistance start end (instructions network) network
|
|
getDistance start end (ih: t) network | start == end = 0
|
|
| otherwise = 1 + getDistance (nodes network ! (start, ih)) end t network
|
|
|
|
getDistanceToEnd :: Network -> Int
|
|
getDistanceToEnd = getDistance "AAA" "ZZZ" []
|