Python and NumPy
Compare greenhouse readings with their targets
BOTIE
Examples, experiments and workspace controls
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.
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
12 18 24 14 22 36 - Target for each greenhouse
- 010
- 120
- 230
- Required result
2 -2 -6 4 2 6
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
- Days by greenhouses
12 15 16 13 - Target for each greenhouse
- 014
- 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 →