Skip to content

Instantly share code, notes, and snippets.

@neuronsguy
neuronsguy / gist:7439552
Created November 12, 2013 22:00
Solution to waterflow problem
"""
Single-pass, simple solution to waterflow problem.
"""
q = [2,5,1,3,1,2,1,7,7,6]
def solve(heights):
water = [0]*len(heights)
total = 0
runoff = 0
for i,height in enumerate(heights):
if i == 0: