Row Shares
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
1 <= rows, columns <= 10- Values are 0 or more and every row has a total above 0
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Sort by First ColumnMedium
- Subtract Row MinimumMedium
- Unit VectorsMedium
- Best Square BlockHard
- Crossing AboveHard
- Current StreakHard
- Finished SudokuHard
- First Time at a LevelHard