2024-12-04 17:15:59 +11:00
|
|
|
{-# OPTIONS_GHC -Wno-x-partial #-}
|
|
|
|
|
2024-12-03 07:10:01 +11:00
|
|
|
import Aoc
|
|
|
|
import Data.List ( group, sort )
|
|
|
|
|
|
|
|
step :: String -> String
|
|
|
|
step = concat . concatMap (\cs -> [show $ length cs, [head cs]]) . group
|
|
|
|
|
|
|
|
part1 :: String -> (Int, String)
|
|
|
|
part1 x = (length after40, after40)
|
|
|
|
where after40 = iterate step x !! 40
|
|
|
|
|
|
|
|
part2 :: p -> String -> Int
|
|
|
|
part2 _ after40 = length (iterate step after40 !! 10) -- only 10 more needed
|
|
|
|
|
2024-12-04 17:15:59 +11:00
|
|
|
main = aocMain' single part1 part2
|