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

16 lines
295 B
Haskell
Raw Normal View History

2023-12-02 23:42:58 +00:00
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