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

13
day08/Part1.hs Normal file
View File

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