Add 2015 day 12 part1

This commit is contained in:
Xavier Morel
2020-12-14 08:51:56 +01:00
parent 518852accb
commit beab34873d
3 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
module Y2015.Day12 (y15day12) where
import Data.Char
-- getToNext :: Char -> String -> String
-- getToNext _ [] = []
-- getToNext c (x:xs)
-- | x == c = []
-- | otherwise = x:(getToNext c xs)
getStructureSum :: String -> Int
getStructureSum s = sum $ map read $ words $ map keepNum s
where keepNum '-' = '-'
keepNum c
| isDigit c = c
| otherwise = ' '
y15day12 :: [String] -> (String, String)
y15day12 (input:_) = (part1, part2)
where part1 = show $ getStructureSum input
part2 = show $ "WIP"

View File

@@ -11,6 +11,8 @@ import Y2015.Day08
import Y2015.Day09
import Y2015.Day10
import Y2015.Day11
import Y2015.Day12
year2015 :: String -> [String] -> (String, String)
year2015 "01" = y15day01
@@ -24,3 +26,4 @@ year2015 "08" = y15day08
year2015 "09" = y15day09
year2015 "10" = y15day10
year2015 "11" = y15day11
year2015 "12" = y15day12