Skip to content

Instantly share code, notes, and snippets.

Avatar

Fernando A fergara

  • Fergara Software
  • Brazil
View GitHub Profile
@fergara
fergara / CalculateRainVolume.groovy
Last active Dec 27, 2015
Groovy version of the "Calculate Rain Volume" algorithm.
View CalculateRainVolume.groovy
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
You can’t perform that action at this time.