advent-of-code-2023/haskell/1-0.hs

15 lines
295 B
Haskell

import Data.Char
digits :: String -> String
digits = filter isDigit
calibrationValue :: String -> Int
calibrationValue x = read [ head $ digits x, last $ digits x ]
main = do
inputs <- readFile "inputs/1.0"
let lns = lines inputs
let res = sum $ map calibrationValue lns
print res