first part of day one
This commit is contained in:
parent
5f91db1d0d
commit
67b33d482c
1 changed files with 15 additions and 0 deletions
15
haskell/1-0.hs
Normal file
15
haskell/1-0.hs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue