Over the Limit

Data with PythonMedium+10 XP+10

Over the Limit

A city has a few air-quality stations. Each one records a pollution reading every day. The readings come as a grid: one row per day and one column per station.

A reading is over the limit when it is strictly greater than limit.

Task: write over_limit(readings, limit) and return a dict:

  • "per_station" — for each station, in column order, how many days it was over the limit,
  • "bad_days" — how many days had every station over the limit at once.

The grid always has at least one day and one station.

Examples

readings = [[42, 55, 38], [61, 70, 52], [35, 48, 30], [58, 66, 49]]
limit = 50
returns {'per_station': [2, 3, 1], 'bad_days': 1}
readings = [[12.5, 18.0], [21.0, 25.5], [9.0, 30.0]]
limit = 20
returns {'per_station': [1, 2], 'bad_days': 1}

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run