Stole Fichte’s parse idea

This commit is contained in:
shu 2019-12-04 09:30:38 +01:00
parent 137e8c22e9
commit a3d0bcde24

View File

@ -1,16 +1,10 @@
import Data.List
main = do
print (day4a 130254 678275)
print (day4b 130254 678275)
print (day4 p [130254..678275])
print (day4 p' [130254..678275])
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 $ show x then acc+1 else acc)
| otherwise = acc
where x' = succ x
day4 p = sum . map (fromEnum . p . show)
p x
| sort x /= x = False