Day 1
This commit is contained in:
parent
539b0e6140
commit
b252ad75ed
3 changed files with 2262 additions and 1 deletions
|
@ -1,2 +1,8 @@
|
|||
import AoC.Day1 as Day1
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello World!"
|
||||
main = do
|
||||
putStrLn "Hello World!"
|
||||
input <- readFile "./input/day1.txt"
|
||||
putStrLn $ show $ Day1.solveA input
|
||||
putStrLn $ show $ Day1.solveB input
|
||||
|
|
2248
input/day1.txt
Normal file
2248
input/day1.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,10 @@
|
|||
|
||||
module AoC.Day1 where
|
||||
|
||||
import Data.List (groupBy,null,sort)
|
||||
|
||||
parseInput :: String -> [[Int]]
|
||||
parseInput = map (map read) . map tail . groupBy (\l r -> (not $ null r)) . lines
|
||||
|
||||
solveA = maximum . map sum . parseInput
|
||||
solveB = sum . take 3 . reverse . sort . map sum . parseInput
|
||||
|
|
Loading…
Reference in a new issue