first part of day one
This commit is contained in:
parent
925f3fc166
commit
21028fe61e
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