From edd8e1fa47c6895b28bbe61ab786ab6dc30471cd Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 11 Dec 2020 10:07:13 +0530 Subject: add day10 --- lib/Utils.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') 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 windows :: Int -> [a] -> [[a]] windows m = foldr (zipWith (:)) (repeat []) . take m . tails + +kadane :: [Int] -> Int +kadane = go 0 0 + where go :: Int -> Int -> [Int] -> Int + go best _ [] = best + go best current (l:ls) = go (max best (current + l)) (max current (current + l)) ls -- cgit v1.2.3