diff --git a/2022/day03/day03.hs b/2022/day03/day03.hs index ba56320..dbd68bb 100644 --- a/2022/day03/day03.hs +++ b/2022/day03/day03.hs @@ -1,14 +1,15 @@ import Data.List import Data.List.Split import Control.Arrow +import Control.Lens main :: IO () main = do input <- lines <$> readFile "input" - print $ (day3a &&& day3b >>> sum *** sum) input + print $ both %~ sum $ (day3a &&& day3b) input day3a :: [String] -> [Int] -day3a = map $ convert . uncurry intersect . (nub *** nub) . (flip splitAt <*> flip div 2 . length) +day3a = map $ convert . uncurry intersect . (both %~ nub) . (flip splitAt <*> flip div 2 . length) day3b :: [String] -> [Int] day3b = map (convert . foldl1 intersect) . chunksOf 3