From: Neil Smith Date: Fri, 2 Dec 2022 09:28:07 +0000 (+0000) Subject: Tidying X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=78b8176f39bae40648a7c08643b28cbefa937fcd;p=advent-of-code-22.git Tidying --- diff --git a/advent01/Main.hs b/advent01/Main.hs index 5cf7d6a..5a45a1e 100644 --- a/advent01/Main.hs +++ b/advent01/Main.hs @@ -3,11 +3,12 @@ import System.Environment import Data.List import Data.List.Split +import Data.Ord main :: IO () main = do dataFileName <- getDataFileName - numStrs <- readFile dataFileName -- "data/advent01.txt" + numStrs <- readFile dataFileName let calories = fmap (fmap (read @Int)) $ splitWhen null $ lines numStrs print $ part1 calories print $ part2 calories @@ -26,5 +27,6 @@ part1 :: [[Int]] -> Int part1 = maximum . fmap sum part2 :: [[Int]] -> Int -part2 = sum . take 3 . reverse . sort . fmap sum +-- part2 = sum . take 3 . reverse . sort . fmap sum +part2 = sum . take 3 . sortOn Down . fmap sum