a07b6fba16
Now to look at other solutions
29 lines
601 B
Haskell
29 lines
601 B
Haskell
import Data.List
|
|
|
|
main = do
|
|
let bottom = 130254
|
|
let top = 678275
|
|
print (day4a bottom top)
|
|
print (day4b bottom top)
|
|
|
|
day4a bottom top = dumbbrute bottom top p 0
|
|
day4b bottom top = dumbbrute bottom top p' 0
|
|
|
|
dumbbrute x y p acc
|
|
| x'<=y = dumbbrute x' y p (if p (numexpl x) then acc+1 else acc)
|
|
| otherwise = acc
|
|
where x' = succ x
|
|
|
|
p x
|
|
| sort x /= x = False
|
|
| nub x == x = False
|
|
| otherwise = True
|
|
|
|
p' x
|
|
| sort x /= x = False
|
|
| 2 `elem` (map length $ group x) = True
|
|
| otherwise = False
|
|
|
|
numexpl 0 = []
|
|
numexpl x = numexpl (x `div` 10) ++ [x `mod` 10]
|