A greenhouse has a line of sensors, and every hour each one sends in a raw reading. The readings arrive as a grid: one row per hour, one column per sensor.
The raw numbers can't be compared yet, for two reasons:
gain[s] belongs to sensor s, so it applies to that sensor's value in every hour.Task: write calibrate(readings, gain), which returns a new grid of the same shape:
readings is a list of rows (one list of numbers per hour) and gain holds one number per sensor. Return a list of lists of plain Python floats, each rounded to 4 decimal places.
For example, with gains [2.0, 0.5, 1.0], an hour that reads [10, 20, 30] calibrates to [20, 10, 30]. Its average is 20, so that hour becomes [0.0, -10.0, 10.0].
Every row of the answer adds up to 0 — that is what taking away a row's own average does. It makes a quick check that you centred in the right direction.