From 911796e471b30f7b1d8358e9d9d179852cfebfc5 Mon Sep 17 00:00:00 2001 From: Crazazy Date: Sun, 1 Dec 2024 12:08:53 +0100 Subject: just now I found out about the unzip function would've saved me a bit of time there ;_; --- src/Day1.idr | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/Day1.idr') diff --git a/src/Day1.idr b/src/Day1.idr index 9018a95..96cf777 100644 --- a/src/Day1.idr +++ b/src/Day1.idr @@ -18,9 +18,6 @@ parseStr str = do nums <- lines str maybe [] pure (parsePair nums) -transposePairs : List (a, b) -> (List a, List b) -transposePairs ls = (map fst ls, map snd ls) - part1 : (List Int, List Int) -> Int part1 inp = sum $ zipWith (\x => \y => abs (x - y)) (sort $ fst inp) (sort $ snd inp) @@ -34,5 +31,5 @@ main : IO () main = do estr <- readFile "data/day1.txt" str <- either (die . show) pure estr - putStrLn $ show $ part1 $ transposePairs $ parseStr str - putStrLn $ show $ part2 $ transposePairs $ parseStr str + putStrLn $ show $ part1 $ unzip $ parseStr str + putStrLn $ show $ part2 $ unzip $ parseStr str -- cgit 1.4.1-2-gfad0