summaryrefslogtreecommitdiff
path: root/day11/day11.hs
diff options
context:
space:
mode:
Diffstat (limited to 'day11/day11.hs')
-rw-r--r--day11/day11.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/day11/day11.hs b/day11/day11.hs
index cf1c4e0..158e951 100644
--- a/day11/day11.hs
+++ b/day11/day11.hs
@@ -28,11 +28,17 @@ blink acc (h:t)
consume :: String -> [Stone]
consume = map atoi . words
+applyN :: Int -> (a -> a) -> a -> a
+applyN n f = foldr (.) id (replicate n f)
+
part1 :: [Stone] -> Int
-part1 = length . last . take 26 . iterate (blink [])
+part1 = length . applyN 25 (blink [])
+
+part2 :: [Stone] -> Int
+part2 = length . applyN 75 (blink [])
main = do
file <- readFile "day11.input"
let stones = consume file
putStrLn ("Part 1: " ++ (show $ part1 stones))
- --putStrLn ("Part 2: " ++ (show $ part2 mp))
+ --putStrLn ("Part 2: " ++ (show $ part2 stones))