Day 11, Part 1

This commit is contained in:
daniele 2024-12-11 21:04:50 +01:00
parent 2288d5c76b
commit 720f1f8559
Signed by: fuxino
GPG Key ID: 981A2B2A3BBF5514

15
Day11/puzzle1.hs Normal file
View File

@ -0,0 +1,15 @@
blinkStone :: Int -> [Int]
blinkStone 0 = [1]
blinkStone s = let ss = show s
nDigit = length ss
in if even nDigit
then map read [take (nDigit `div` 2) ss, drop (nDigit `div` 2) ss]
else [s * 2024]
blink :: Int -> [Int] -> [Int]
blink 0 xs = xs
blink n xs = blink (n - 1) $ concatMap blinkStone xs
main = do
contents <- words <$> readFile "day11.txt"
print . length . blink 25 $ map read contents