All problems
Transportation Simplex Step
Problem
Build an initial basic feasible solution for a transportation problem with the northwest corner rule.
Repeatedly allocate the smaller of the current supply and demand at the current cell, then advance past the row or column that becomes exhausted. Return the allocation matrix.
Hint
Move right when demand is exhausted and down when supply is exhausted.
Test cases
case 1
in: [[3,2],[2,3]]
expected: [[2,1],[0,2]]
case 2
in: [[5],[2,3]]
expected: [[2,3]]
case 3
in: [[0,4],[1,3]]
expected: [[0,0],[1,3]]
case 4
in: [[1,1],[1,1]]
expected: [[1,0],[0,1]]
Starter codePython
def transportation_step(supply, demand):
# Your code here
pass4 test cases · run your code against them in the editor