Advent of Code 2025
at main 643 B view raw
1module Day6 where 2 3import Data.List 4import Debug.Trace 5import Util 6 7solveProblem :: ([Int], String) -> Int 8solveProblem (terms, "+") = sum terms 9solveProblem (terms, "*") = product terms 10 11part1 :: String -> String 12part1 input = 13 let l = lines input 14 terms = map (map read) $ transpose $ map words $ init l 15 ops = words $ last l 16 in 17 show $ 18 sum $ 19 map solveProblem (zip terms ops) 20 21part2 :: String -> String 22part2 input = 23 let l = lines input 24 terms :: [[Int]] = map (map read) $ splitOn null $ map trim $ transpose $ init l 25 ops = words $ last l 26 in show $ sum $ map solveProblem (zip terms ops)