projects
/
advent-of-code-21.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
30f2ac1
)
A little point-free tweak
author
Neil Smith
<neil.git@njae.me.uk>
Wed, 1 Dec 2021 16:34:27 +0000
(16:34 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Wed, 1 Dec 2021 16:34:27 +0000
(16:34 +0000)
advent01/Main.hs
patch
|
blob
|
history
diff --git
a/advent01/Main.hs
b/advent01/Main.hs
index 535fdf45410bf4884cc4103e426c6e25c079b69a..9d627260e2887769b4e74d8f7546fcc94bac9b25 100644
(file)
--- a/
advent01/Main.hs
+++ b/
advent01/Main.hs
@@
-12,7
+12,7
@@
part1 = countIncreasing
part2 :: [Int] -> Int
part2 nums = countIncreasing $ map sum windows
- where windows = filter (
\w -> length w == 3
) $ map (take 3) $ tails nums
+ where windows = filter (
(== 3) . length
) $ map (take 3) $ tails nums
countIncreasing :: [Int] -> Int
countIncreasing nums = length $ filter (> 0) $ zipWith (-) (tail nums) nums