This commit is contained in:
2023-12-01 17:25:07 +01:00
commit 787691d640
5 changed files with 87 additions and 0 deletions

14
day01/Part1.hs Normal file
View File

@@ -0,0 +1,14 @@
module Part1 where
import Commons
getCalibrationValuePart :: CalibrationLine -> Char
getCalibrationValuePart (h: _) | h >= '0' && h <= '9' = h
getCalibrationValuePart (_: t) = getCalibrationValuePart t
getCalibrationValue :: CalibrationLine -> Integer
getCalibrationValue line = read [(getCalibrationValuePart line), (getCalibrationValuePart (reverse line))]
getCalibrationValues :: CalibrationDocument -> [Integer]
getCalibrationValues (h: []) = [(getCalibrationValue h)]
getCalibrationValues (h: t) = ((getCalibrationValue h): (getCalibrationValues t))