Add 2015 day 10

This commit is contained in:
Xavier Morel
2020-12-09 18:50:34 +01:00
parent dd8f2ae9dc
commit 12a8275359
3 changed files with 17 additions and 0 deletions

View File

@@ -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