Parsing tweaks.
[advent-of-code-19.git] / advent03 / src / advent03part1.hs
index 370294337291358c8a86b55bb9b110b5f316e7f0..5647ce5326d4c492cfdb6db4acf7195a862307e1 100644 (file)
@@ -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
@@ -88,7 +86,7 @@ integer = lexeme L.decimal
 symb = L.symbol sc
 comma = symb ","
 
-wiresP = some pathP
+wiresP = many pathP
 pathP = segmentP `sepBy1` comma
 
 segmentP = segmentify <$> directionP <*> integer