FunctionRacerProblemsRace

Cells Above Row Average

MediumNumPyPython

Return how many cells of the 2-D array grid are strictly greater than the average of the row they sit in. Hint: grid.mean(axis=1, keepdims=True) gives column of averages that broadcasts against grid.

Example 1

grid [[1,2,6],[5,5,5]]
returns 1

Row 0 averages 3, and only 6 is above it. Row 1 averages 5 and nothing is above it.

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