import Data.List

main = print $ day4 [130254..678275] <$> [p,p']

day4 r f = (length . filter f . map show) r

p x | sort x /= x = False
    | nub x == x = False
    | otherwise = True

p' x = 2 `elem` map length (group x) && p x
