Minimum grid path cost
Return the minimum sum along a top-left to bottom-right path moving right or down in a nonnegative rectangular grid. Empty input returns zero.
above, left, value = 8, 3, 4
print(value + min(above, left))Reason about the state
For each cell add its cost to the cheaper predecessor. A rolling row stores the previous row until each column is overwritten. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Return the minimum sum along a top-left to bottom-right path moving right or down in a nonnegative rectangular grid. Empty input returns zero.
The explanation opens here once every check passes.