X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-19.git;a=blobdiff_plain;f=advent03%2Fsrc%2Fadvent03part1.hs;h=e2beb38e974e5da7e3a7bcfdebc0bf397fb650e4;hp=370294337291358c8a86b55bb9b110b5f316e7f0;hb=52bfc1a213695ffc0a5107a0b1b7e094b5841423;hpb=1915ebe9124a2075ed2212a6817f3e441c0c36fb diff --git a/advent03/src/advent03part1.hs b/advent03/src/advent03part1.hs index 3702943..e2beb38 100644 --- a/advent03/src/advent03part1.hs +++ b/advent03/src/advent03part1.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.Set as S import Linear (V2(..), (^+^), (^-^), (*^), (*^)) @@ -46,9 +46,7 @@ closest points = S.findMin $ S.map manhattan points crossovers :: [Path] -> Visited crossovers travelledPaths = - foldl' S.intersection - (_visited $ head travelledPaths) - (map _visited $ drop 1 travelledPaths) + foldl1' S.intersection $ map _visited travelledPaths travelAllPaths :: [[Segment]] -> [Path] travelAllPaths = map travelPath