-- https://adventofcode.com/2024/day/1 (mit dank an flo) import Data.String gather : IO (List (Int, Int)) gather = do line <- getLine case map parsePositive (words line) of [Just left, Just right] => do rest <- gather pure ((left, right) :: rest) _ => pure [] solve : List (Int, Int) -> Int solve stuff = let left = sort $ map fst stuff right = sort $ map snd stuff in sum $ zipWith (abs .: (-)) left right main : IO () main = gather >>= printLn . solve