control.lens instead of control.arrow
This commit is contained in:
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
|
||||
|
Loading…
Reference in New Issue
Block a user