X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-19.git;a=blobdiff_plain;f=advent03%2Fsrc%2Fadvent03.hs;h=a863ffef9ca2a09ac081a321c6bbc8f1f2c539a1;hp=ea2645ef7b4d9a3b82434b8913ac882006896808;hb=52bfc1a213695ffc0a5107a0b1b7e094b5841423;hpb=1915ebe9124a2075ed2212a6817f3e441c0c36fb diff --git a/advent03/src/advent03.hs b/advent03/src/advent03.hs index ea2645e..a863ffe 100644 --- a/advent03/src/advent03.hs +++ b/advent03/src/advent03.hs @@ -8,7 +8,7 @@ import Text.Megaparsec.Char import qualified Text.Megaparsec.Char.Lexer as L import qualified Control.Applicative as CA -import Data.List (foldl') +import Data.List (foldl', foldl1') import qualified Data.Map as M import Data.Map ((!)) @@ -56,9 +56,7 @@ shortestPaths crossings = minimum $ M.elems crossings crossovers :: [Path] -> Visited crossovers travelledPaths = - foldl' (M.intersectionWith (+)) - (_visited $ head travelledPaths) - (map _visited $ drop 1 travelledPaths) + foldl1' (M.intersectionWith (+)) $ map _visited travelledPaths travelAllPaths :: [[Segment]] -> [Path] travelAllPaths = map travelPath