FunctionRacerProblemsRace

Row Shares

MediumNumPyPython

Return a 2-D array of the same shape as grid in which every cell is divided by the total of its row, so each row of the result adds up to 1. Every row of grid has a total above 0.

Example 1

grid [[1,3],[2,2]]
returns [[0.25,0.75],[0.5,0.5]]

Row 0 totals 4, giving 0.25 and 0.75. Row 1 totals 4, giving 0.5 and 0.5.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems