This commit is contained in:
2023-12-08 14:10:45 +01:00
parent 1326fe7e33
commit de65de6292
5 changed files with 93 additions and 0 deletions

12
day08/Part1.hs Normal file
View File

@@ -0,0 +1,12 @@
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" []