1.2 solved
This commit is contained in:
parent
328b31a1fa
commit
ec5c25c4af
7
app/1.hs
7
app/1.hs
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user