From 21028fe61e90794ea24afb236888a9b2bc013562 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Sun, 3 Dec 2023 00:42:58 +0100 Subject: [PATCH] first part of day one --- haskell/1-0.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 haskell/1-0.hs diff --git a/haskell/1-0.hs b/haskell/1-0.hs new file mode 100644 index 0000000..7af23d4 --- /dev/null +++ b/haskell/1-0.hs @@ -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 + +