diff options
Diffstat (limited to 'lib/Utils.hs')
-rw-r--r-- | lib/Utils.hs | 6 |
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 | ||
44 | windows :: Int -> [a] -> [[a]] | 44 | windows :: Int -> [a] -> [[a]] |
45 | windows m = foldr (zipWith (:)) (repeat []) . take m . tails | 45 | windows m = foldr (zipWith (:)) (repeat []) . take m . tails |
46 | |||
47 | kadane :: [Int] -> Int | ||
48 | kadane = 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 | ||