Function for calculating downstream summation of a greedy grid output

Prabhas' Improvements
Refactoring of long sighted algorithm

incorporating Prabhas' help