aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-11 04:37:13 +0000
committerAkshay <[email protected]>2020-12-11 04:37:13 +0000
commitedd8e1fa47c6895b28bbe61ab786ab6dc30471cd (patch)
treeea63292c4ce916c9f34ae8ed205f33dd2d3b9d88 /lib
parentac3191ae40b8df0873f2e04f5bc1017322941b5d (diff)
add day10
Diffstat (limited to 'lib')
-rw-r--r--lib/Utils.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Utils.hs b/lib/Utils.hs
index 1381f16..61c4e49 100644
--- a/lib/Utils.hs
+++ b/lib/Utils.hs
@@ -43,3 +43,9 @@ sublists = concatMap inits . tails
43 43
44windows :: Int -> [a] -> [[a]] 44windows :: Int -> [a] -> [[a]]
45windows m = foldr (zipWith (:)) (repeat []) . take m . tails 45windows m = foldr (zipWith (:)) (repeat []) . take m . tails
46
47kadane :: [Int] -> Int
48kadane = go 0 0
49 where go :: Int -> Int -> [Int] -> Int
50 go best _ [] = best
51 go best current (l:ls) = go (max best (current + l)) (max current (current + l)) ls