-- https://adventofcode.com/2024/day/1 [mit dank an philip] import Data.String import System.File getLines : List String -> IO (List String) getLines s = do eof <- fEOF stdin if eof then pure s else getLine >>= getLines . (:: s) parse : IO (List (List Int)) parse = getLines [] >>= pure . map (catMaybes . map parsePositive . words) main : IO () main = do l <- parse case (transpose l) of [x , y] => printLn $ sum $ zipWith (abs .: (-)) (sort x) (sort y) _ => pure ()