Stole Fichte’s parse idea
This commit is contained in:
parent
137e8c22e9
commit
a3d0bcde24
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user