import Data.List (sort, transpose) import Data.List.Split (splitOn) solve :: [[Int]] -> Int solve = sum . map abs . (\[x, xx] -> zipWith (-) x xx) . map sort main :: IO () main = print . solve . transpose . map parseLine . lines =<< readFile "data.txt" where parseLine = map read . filter (not . null) . splitOn " "