diff options
Diffstat (limited to 'execs/Day09.hs')
-rw-r--r-- | execs/Day09.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/execs/Day09.hs b/execs/Day09.hs index f1c41f2..7bf4908 100644 --- a/execs/Day09.hs +++ b/execs/Day09.hs | |||
@@ -1,9 +1,9 @@ | |||
1 | 1 | ||
2 | module Main where | 2 | module Main where |
3 | 3 | ||
4 | import Utils | 4 | import Data.Bifunctor |
5 | import Data.List (inits, tails, find, sort) | 5 | import Data.List (find, inits, sort, tails) |
6 | import Data.Bifunctor | 6 | import Utils |
7 | 7 | ||
8 | parseLine :: String -> Int | 8 | parseLine :: String -> Int |
9 | parseLine = read | 9 | parseLine = read |
@@ -13,12 +13,12 @@ doCheck preamble target = target `elem` p | |||
13 | where p = [x + y | x <- preamble, y <- preamble, x /= y] | 13 | where p = [x + y | x <- preamble, y <- preamble, x /= y] |
14 | 14 | ||
15 | checkAll :: [[Int]] -> [Int] -> [(Int, Bool)] | 15 | checkAll :: [[Int]] -> [Int] -> [(Int, Bool)] |
16 | checkAll = zipWith (\p t -> (t, doCheck p t)) | 16 | checkAll = zipWith (\p t -> (t, doCheck p t)) |
17 | 17 | ||
18 | findWeakness :: [[Int]] -> Int -> Int | 18 | findWeakness :: [[Int]] -> Int -> Int |
19 | findWeakness subs target = minimum t + maximum t | 19 | findWeakness subs target = minimum t + maximum t |
20 | where Just t = find ((== target) . sum) subs | 20 | where Just t = find ((== target) . sum) subs |
21 | 21 | ||
22 | main :: IO () | 22 | main :: IO () |
23 | main = do | 23 | main = do |
24 | n <- map parseLine . lines <$> readFile "input/09" | 24 | n <- map parseLine . lines <$> readFile "input/09" |