From 12a8275359d2b6b2e0ead3b66465154504fbd7f1 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 9 Dec 2020 18:50:34 +0100 Subject: [PATCH] Add 2015 day 10 --- haskellAoC/inputs/2015/10 | 1 + haskellAoC/src/Y2015/Day10.hs | 14 ++++++++++++++ haskellAoC/src/Y2015/Days.hs | 2 ++ 3 files changed, 17 insertions(+) create mode 100644 haskellAoC/inputs/2015/10 create mode 100644 haskellAoC/src/Y2015/Day10.hs diff --git a/haskellAoC/inputs/2015/10 b/haskellAoC/inputs/2015/10 new file mode 100644 index 0000000..1742d89 --- /dev/null +++ b/haskellAoC/inputs/2015/10 @@ -0,0 +1 @@ +1113222113 \ No newline at end of file diff --git a/haskellAoC/src/Y2015/Day10.hs b/haskellAoC/src/Y2015/Day10.hs new file mode 100644 index 0000000..b960fce --- /dev/null +++ b/haskellAoC/src/Y2015/Day10.hs @@ -0,0 +1,14 @@ +module Y2015.Day10 (y15day10) where + +import Data.List + +lookAndSay :: String -> String +lookAndSay input = concat $ map describe_group $ group input + where describe_group g = (show $ length g) ++ (head g):"" + + +y15day10 :: [String] -> (String, String) +y15day10 (input:_) = (part1, part2) + where part1 = show $ length $ part1resp + part2 = show $ length $ head $ drop 10 $ iterate lookAndSay part1resp + part1resp = head $ drop 40 $ iterate lookAndSay input diff --git a/haskellAoC/src/Y2015/Days.hs b/haskellAoC/src/Y2015/Days.hs index b02db39..d5783af 100644 --- a/haskellAoC/src/Y2015/Days.hs +++ b/haskellAoC/src/Y2015/Days.hs @@ -9,6 +9,7 @@ import Y2015.Day06 import Y2015.Day07 import Y2015.Day08 import Y2015.Day09 +import Y2015.Day10 year2015 :: String -> [String] -> (String, String) year2015 "01" = y15day01 @@ -20,3 +21,4 @@ year2015 "06" = y15day06 year2015 "07" = y15day07 year2015 "08" = y15day08 year2015 "09" = y15day09 +year2015 "10" = y15day10