module Day2A where import qualified Data.IntMap as IM import Data.Char (ord) out :: String -> Int -> Int out id' n = min (length $ IM.filter (==n) counts) 1 where counts = foldr (\c -> IM.insertWith (+) (ord c) 1) IM.empty id' handleId :: String -> (Int, Int) handleId id' = (out id' 2, out id' 3) add2 :: Num a => (a, a) -> (a, a) -> (a, a) add2 (a, b) (x, y) = (a + x, b + y) main :: IO () main = interact $ show . uncurry (*) . counts . lines where counts = foldr (add2 . handleId) (0, 0)