Skip to content

Instantly share code, notes, and snippets.

@lauzi
Created December 4, 2014 16:24
Show Gist options
  • Save lauzi/f94b5db8f5cbed8f0fd6 to your computer and use it in GitHub Desktop.
Save lauzi/f94b5db8f5cbed8f0fd6 to your computer and use it in GitHub Desktop.
-- 1
main = interact $ show . sum . map read . tail . lines
-- 2
f [a, b, c] = if a <= b then 0 else (a-b)*c
main = interact $ show . sum . map (f . map read . words) . tail . lines
-- 3
import Control.DeepSeq
f (t : _ : xs) = psums `deepseq` maximum diffs
where psums = scanl (+) 0 xs
diffs = zipWith (-) (drop t psums) psums
main = interact $ show . f . map read . words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment