diff options
author | Crazazy | 2024-12-01 12:08:53 +0100 |
---|---|---|
committer | Crazazy | 2024-12-01 12:08:53 +0100 |
commit | 911796e471b30f7b1d8358e9d9d179852cfebfc5 (patch) | |
tree | f0c9cbba8ba9bb220c658bacd6fff5a93c4cad50 | |
parent | 5ff7dbf234fd768c040acb0ff8e5718d50a862d8 (diff) |
just now I found out about the unzip function
would've saved me a bit of time there ;_;
-rw-r--r-- | src/Day1.idr | 7 |
1 files changed, 2 insertions, 5 deletions
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 |