Add version with parsing

I found this highly unnecessary but whatever
This commit is contained in:
shu 2019-12-04 16:18:23 +01:00
parent 6e9b85b894
commit fd626a2f30

View File

@ -0,0 +1,17 @@
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