1.1 solved

This commit is contained in:
2024-12-01 10:56:24 +01:00
parent 680cbe86e7
commit 328b31a1fa
31 changed files with 1392 additions and 0 deletions

26
app/1.hs Normal file
View File

@ -0,0 +1,26 @@
{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Redundant <&>" #-}
module Main where
import Data.Functor
import Data.List.Split
import Data.Char
import Data.Function
import Data.List
parse :: String -> ([Int], [Int])
parse = unzip .
((\case
[a,b] -> (read a, read b)
e -> error $ "Parsing failed on: " ++ show e
) <$>) .
(filter (/= mempty) <$>) .
(splitWhen isSpace <$>) .
lines
solve1 :: ([Int], [Int]) -> Int
solve1 = sum . uncurry (zipWith ((abs .) . (-)) `on` sort)
main :: IO ()
main = readFile "inputs/1" <&> solve1 . parse >>= print

0
app/10.hs Normal file
View File

0
app/11.hs Normal file
View File

0
app/12.hs Normal file
View File

0
app/13.hs Normal file
View File

0
app/14.hs Normal file
View File

0
app/15.hs Normal file
View File

0
app/16.hs Normal file
View File

0
app/17.hs Normal file
View File

0
app/18.hs Normal file
View File

0
app/19.hs Normal file
View File

0
app/2.hs Normal file
View File

0
app/20.hs Normal file
View File

0
app/21.hs Normal file
View File

0
app/22.hs Normal file
View File

0
app/23.hs Normal file
View File

0
app/24.hs Normal file
View File

0
app/3.hs Normal file
View File

0
app/4.hs Normal file
View File

0
app/5.hs Normal file
View File

0
app/6.hs Normal file
View File

0
app/7.hs Normal file
View File

0
app/8.hs Normal file
View File

0
app/9.hs Normal file
View File