#! /usr/bin/env stack -- stack --resolver lts-12.20 --install-ghc script module Main where import Control.Arrow ((&&&)) import Data.List (group, sort) main :: IO () main = interact $ show . \input -> let codes = lines input :: [[Char]] counts = map (map (head &&& length) . group . sort) codes :: [[(Char, Int)]] twos = length $ filter (any ((== 2) . snd)) counts threes = length $ filter (any ((== 3) . snd)) counts in (twos, threes, twos * threes)