import Data.List import Data.List.Split part1 fst sec = let sfst = sort fst ssec = sort sec z = map (abs) $ zipWith (-) sfst ssec in sum z part2 fst sec = sum $ map (\x -> x * (length $ filter (== x) sec)) fst main = do file <- readFile "day01.input" let lns = lines file let lsts = transpose $ map (splitOn " ") lns let fst = map (read::String->Int) $ head lsts let sec = map (read::String->Int) $ head $ reverse lsts putStrLn ("Part 1: " ++ (show $ part1 fst sec)) putStrLn ("Part 2: " ++ (show $ part2 fst sec))