AoC/2019/day4/day4_withparse.hs

18 lines
392 B
Haskell
Raw Normal View History

import Data.List
import Data.List.Split
main = do
print (day4 p $ range "130254-678275")
print (day4 p' $ range "130254-678275")
range :: String -> [Int]
range input = [a..b] where [a,b] = map read $ splitOn "-" input
day4 p = sum . map (fromEnum . p . show)
p x | sort x /= x = False
| nub x == x = False
| otherwise = True
p' x = 2 `elem` (map length $ group x) && p x