Peaks of Full Days

Data with PythonHard+10 XP+10

Peaks of Full Days

A greenhouse sensor takes per_day readings every day. They arrive as one long list: all of day 0's readings, then all of day 1's, and so on.

The sensor was switched off part-way through the last day, so the list may end with a few readings that don't make a full day.

Task: write daily_peaks(readings, per_day) and return the highest reading of each full day, as a plain list, in day order.

  • Leftover readings at the end that don't make a full day are ignored.
  • If there isn't even one full day, return an empty list.
  • per_day is always at least 1.

Examples

readings = [18, 22, 25, 20, 17, 24, 23, 19]
per_day = 4
returns [25, 24]
readings = [12.5, 14.0, 13.5, 15.5, 16.0, 11.0, 18.5]
per_day = 3
returns [14.0, 16.0]

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