Skip to content

Instantly share code, notes, and snippets.

View fergara's full-sized avatar

Fernando A fergara

View GitHub Profile
@fergara
fergara / CalculateRainVolume.groovy
Last active December 27, 2015 02:09
Groovy version of the "Calculate Rain Volume" algorithm.
def walls = [ 2, 5, 1, 2, 3, 4, 7, 7, 6 ]
println(calculateVolume(walls))
assert 10 == calculateVolume(walls)
def calculateVolume(land) {
def leftMax = 0
def rightMax = 0
def left = 0