Skip to content

Instantly share code, notes, and snippets.

@ssartell
Created April 26, 2019 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ssartell/7d23e93d39b7c2bac1742f2966b5cbb1 to your computer and use it in GitHub Desktop.
Save ssartell/7d23e93d39b7c2bac1742f2966b5cbb1 to your computer and use it in GitHub Desktop.
/* LINQ Puzzle #14 *******************************************************
Summary: Given an array of integer, imagine they represent the cross section of some terrain with mountains and valleys.
It rains a bunch, but the ground isn't porous so the water fills up every valley as much as possible. Assuming the edges of
the array are the ends of the earth and water can exit there, how much total water fills the terrain?
Sample Input: { 4, 6, 5, 2, 0, 1, 3, 2, 4, 2 }
Sample Output: 12
************************************************************************/
var ints = new[] { 4, 6, 5, 2, 0, 1, 3, 2, 4, 2 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment