day 5: NEEDS MOAR ARROWS

This commit is contained in:
Gattix 2021-12-12 01:14:47 +01:00
parent e4bae770de
commit 51a8583a97

@ -1,12 +1,14 @@
import qualified Data.Map as M
import Data.List.Split
import Control.Arrow
import Control.Monad
main :: IO ()
main = do
input <- map (map read . filter (/="->")) <$> map (splitOneOf ", ") <$> lines <$> readFile "input"
let part1inp = filterOrth input
print $ length $ M.filter (> 1) $ M.fromListWith (+) (toMap part1inp)
print $ length $ M.filter (> 1) $ M.fromListWith (+) (toMap input)
let process = length . M.filter (> 1) . M.fromListWith (+) . toMap
print $ join (***) process $ (filterOrth input,input)
filterOrth :: [[Int]] -> [[Int]]
filterOrth [] = []