diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2024-12-14 23:18:00 +0100 | 
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2024-12-14 23:18:00 +0100 | 
| commit | dbb18933b67481cc9ddfd7e8ab4aefa1d65e6a38 (patch) | |
| tree | d72628297d0f592c8bbd28a6ae671aba65fa48ed /2024 | |
| parent | 1697486526af935cd7bac02652ee1154d066b551 (diff) | |
Diffstat (limited to '2024')
| -rw-r--r-- | 2024/11.hs | 14 | 
1 files changed, 3 insertions, 11 deletions
@@ -1,19 +1,11 @@ -import qualified Data.Map.Strict as Map +import qualified Data.IntMap.Strict as Map  main :: IO ()  main = do    s0 <- map (read @Int) . words <$> getContents -  let ndigs10 0 = 1 -      ndigs10 n = pre (4::Int) -        where pre p | n >= 10 ^ p = pre (2*p) -                    | otherwise = bin 0 p -              bin lo hi | lo == hi - 1 = hi -                        | n >= 10 ^ mid = bin mid hi -                        | otherwise = bin lo mid -                where mid = (lo + hi) `quot` 2    let splitHalf n = -        let nd = ndigs10 n -        in if even nd then Just $ n `quotRem` (10 ^ (ndigs10 n `quot` 2)) +        let nd = length (show n) +        in if even nd then Just $ n `quotRem` (10 ^ (nd `quot` 2))                        else Nothing    let blink =          Map.fromListWith (+)  | 
