From: Neil Smith Date: Sun, 1 Dec 2024 16:54:15 +0000 (+0000) Subject: Tidying X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=330825677129e9e1c1c9bb39c497f18896bc4fa5;p=advent-of-code-24.git Tidying --- diff --git a/advent01/Main.hs b/advent01/Main.hs index b304759..8ba212e 100644 --- a/advent01/Main.hs +++ b/advent01/Main.hs @@ -1,7 +1,6 @@ -- Writeup at https://work.njae.me.uk/2023/12/01/advent-of-code-2023-day-01/ import AoC --- import Data.Char import Data.List import qualified Data.MultiSet as MS @@ -10,11 +9,10 @@ main = do dataFileName <- getDataFileName text <- readFile dataFileName let pairs = fmap readPair $ lines text - print pairs print $ part1 pairs print $ part2 pairs -part1 :: [(Int, Int)] -> Int +part1, part2 :: [(Int, Int)] -> Int part1 pairs = sum $ zipWith absDiff (sort lefts) (sort rights) where (lefts, rights) = unzip pairs absDiff a b = abs (a - b) diff --git a/adventofcode24.cabal b/adventofcode24.cabal index 8126db1..f922676 100644 --- a/adventofcode24.cabal +++ b/adventofcode24.cabal @@ -16,6 +16,9 @@ extra-doc-files: CHANGELOG.md common warnings ghc-options: -Wall +common common-modules + other-modules: AoC + common common-extensions default-extensions: AllowAmbiguousTypes , ApplicativeDo @@ -70,6 +73,6 @@ executable adventofcode24 default-language: GHC2021 executable advent01 - import: warnings, common-extensions, build-directives + import: warnings, common-extensions, build-directives, common-modules main-is: advent01/Main.hs build-depends: multiset