control.lens instead of control.arrow

This commit is contained in:
Gattix 2022-12-03 19:05:28 +01:00
parent 66b1e7128b
commit d9b902d551

@ -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