projects
/
advent-of-code-21.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added writeup links
[advent-of-code-21.git]
/
advent01
/
Main.hs
diff --git
a/advent01/Main.hs
b/advent01/Main.hs
index a52bf9c1a6bd597c69118aab6f859eb5eb1cb3af..8c95a92d4c83caa89d16d5d2a4581a180e1bb488 100644
(file)
--- a/
advent01/Main.hs
+++ b/
advent01/Main.hs
@@
-1,3
+1,5
@@
+-- Writeup at https://work.njae.me.uk/2021/12/01/advent-of-code-2021-day-1/
+
import Data.List
main :: IO ()
import Data.List
main :: IO ()
@@
-15,5
+17,4
@@
part2 nums = countIncreasing $ map sum windows
where windows = filter ((== 3) . length) $ map (take 3) $ tails nums
countIncreasing :: [Int] -> Int
where windows = filter ((== 3) . length) $ map (take 3) $ tails nums
countIncreasing :: [Int] -> Int
--- countIncreasing nums = length $ filter (> 0) $ zipWith (-) (tail nums) nums
countIncreasing nums = length $ filter (uncurry (>)) $ zip (tail nums) nums
countIncreasing nums = length $ filter (uncurry (>)) $ zip (tail nums) nums