fd626a2f30
I found this highly unnecessary but whatever
18 lines
392 B
Haskell
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
|