Python and NumPy

Compare greenhouse readings with their targets

BOTIE

Subtract one target per greenhouse from every day's readings. Preserve both the day rows and greenhouse columns.
Ready to test
0 passed · 0 failed · 1 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Subtract one target per greenhouse from every day's readings. Preserve both the day rows and greenhouse columns.

Each greenhouse has its own target. Botie must reuse those targets across days without attaching them to the wrong columns.

Subtract the supplied target vector from every day's row using the column-aligned comparison.

Examples and results
Days by greenhouses
121824
142236
Target for each greenhouse
  1. 010
  2. 120
  3. 230
Required result
2-2-6
426
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

The workshop tool handles a reference vector across rows. It does not implement every possible NumPy broadcasting pattern. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

A square report with different greenhouse targets

This check uses the pieces from “Keep a target attached to each greenhouse”.

BOTIE

There are two days and two greenhouses, so the dimensions alone cannot tell us which axis means what. The first greenhouse has target 14 and the second has target 10. Predict each reading's departure in the original table layout.
Days by greenhouses
1215
1613
Target for each greenhouse
  1. 014
  2. 110

Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

What does the length of the target vector tell you, and what label information must accompany that length?

Compatible shapes are necessary, but meaningful broadcasting also depends on matching dimension roles.

The workshop tool handles a reference vector across rows. It does not implement every possible NumPy broadcasting pattern.

Work through the Python challenges →
Continue the courseAsk Each Row a Question →