Day 8
This commit is contained in:
13
day08/Part1.hs
Normal file
13
day08/Part1.hs
Normal 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" []
|
||||
Reference in New Issue
Block a user