Skip to content

Instantly share code, notes, and snippets.

@neuronsguy
neuronsguy / gist:7439552
Created Nov 12, 2013
Solution to waterflow problem
View gist:7439552
"""
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: