1.2 solved

This commit is contained in:
pingu 2024-12-01 11:00:28 +01:00
parent 328b31a1fa
commit ec5c25c4af

View File

@ -22,5 +22,10 @@ parse = unzip .
solve1 :: ([Int], [Int]) -> Int
solve1 = sum . uncurry (zipWith ((abs .) . (-)) `on` sort)
solve2 :: ([Int], [Int]) -> Int
solve2 (as,bs) = foldr (\a b -> b + a * length (filter (==a) bs)) 0 as
main :: IO ()
main = readFile "inputs/1" <&> solve1 . parse >>= print
main = readFile "inputs/1" <&> parse >>= \i ->
print (solve1 i) >>
print (solve2 i)