AoC/2019/day4/day4_withparse.hs
shu fd626a2f30 Add version with parsing
I found this highly unnecessary but whatever
2019-12-04 16:18:23 +01:00

18 lines
392 B
Haskell

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