Skip to content

Instantly share code, notes, and snippets.

@Sophia-Gold
Last active August 14, 2017 03:51
Show Gist options
  • Select an option

  • Save Sophia-Gold/bec46bfcd0011b1b5e98a43f0847b399 to your computer and use it in GitHub Desktop.

Select an option

Save Sophia-Gold/bec46bfcd0011b1b5e98a43f0847b399 to your computer and use it in GitHub Desktop.
from Guy Steele's talk, "Four Solutions to a Trivial Problem"
(defn histo-water [l]
(->> l
(map-indexed #(vector
%2
(reduce max 0 (subvec l 0 %1))
(reduce max 0 (subvec l %1))))
(map #(- (min (second %) (nth % 2)) (first %)))
(filter pos?)
(reduce +)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment