From d9b902d551915c8bdf406bf86f18cad8ca4d44f9 Mon Sep 17 00:00:00 2001 From: Gattix Date: Sat, 3 Dec 2022 19:05:28 +0100 Subject: [PATCH] control.lens instead of control.arrow --- 2022/day03/day03.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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