Skip to content

Instantly share code, notes, and snippets.

Avatar

Péter Diviánszky divipp

  • Budapest
View GitHub Profile
View gist:7563697
water is = w1 + w2 + t1 - length is * m1 where
(t1,m1,w1) = foldl f (0,0,0) is
(t2,m2,w2) = foldl f (0,0,0) $ reverse is
f (t,m,w) i = (t+i, max m i, w + max 0 (m-i))
View gist:7453089
water is = w1 + w2 + t1 - length is * m1 where
(t1,m1,w1) = foldr f (0,0,0) is
(t2,m2,w2) = foldr f (0,0,0) $ reverse is
f i (t,m,w) = (t+i, max m i, w + max 0 (m-i))
You can’t perform that action at this time.