Add version with parsing
I found this highly unnecessary but whatever
This commit is contained in:
parent
6e9b85b894
commit
fd626a2f30
|
@ -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
|
Loading…
Reference in New Issue
Block a user