14 lines
364 B
Haskell
14 lines
364 B
Haskell
{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
|
|
import Aoc
|
|
import Text.Regex.PCRE
|
|
import Data.List.Split ( splitOn )
|
|
|
|
part1 :: [String] -> Int
|
|
part1 = sum . map (sum . map (product . map read . tail) . (=~ "mul\\((\\d+),(\\d+)\\)"))
|
|
|
|
part2 :: [String] -> Int
|
|
part2 = part1 . map (head . splitOn "don't()") . splitOn "do()" . concat
|
|
|
|
main :: IO ()
|
|
main = aocMain id part1 part2 |