Introductory Mathematics

One price list, a whole page of purchases

BOTIE

Collect the loaf and milk lists, then arrange the result so bread precedes milk within every customer row.
Ready to test
0 passed · 0 failed · 2 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

Change just the bread price. Before looking at the bills, decide which customer should see the largest increase. Then change one customer's purchase and check whether anyone else's bill changes.

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

Collect the loaf and milk lists, then arrange the result so bread precedes milk within every customer row.

Let's return to the purchases from our bookkeeping problem. Before trying to recover unknown prices, we will start with prices we know and work out the bills. One customer's bill is straightforward. Now suppose we have a whole page of purchases. We need to keep each customer's quantities together and apply the same prices to every customer. A table gives us a place for each quantity; we will build the calculation that uses it.

Inspect the component calculation
Swap rows and columns(
  Matrix: Collect two results(
    First result: Loaves for each customer
    Second result: Milk bottles for each customer
  )
)
Examples and results
Loaves for each customer
  1. 01
  2. 13
  3. 22
Milk bottles for each customer
  1. 02
  2. 11
  3. 20
Required result
12
31
20
Loaves for each customer
  1. 00
  2. 12
Milk bottles for each customer
  1. 03
  2. 11
Required result
03
21
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

These are invented purchases. The prices are given, and we calculate bills from them. Recovering unknown prices from known bills would require solving a system of equations, which is a different operation. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.

One customer, fractional prices

This check uses the pieces from “Apply one price list to every customer”.

BOTIE

Only one customer arrives, buying four loaves and no milk. The price vector still lists bread before milk. Predict the bill while keeping the result in customer order.
Loaves for each customer
  1. 04
Milk bottles for each customer
  1. 00
Prices: bread, then milk
  1. 01.5
  2. 12.25

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 a row identify, and why must the price order match the columns rather than the rows?

A matrix can apply one weighted calculation to many observations while retaining their identities.

These are invented purchases. The prices are given, and we calculate bills from them. Recovering unknown prices from known bills would require solving a system of equations, which is a different operation.

Work through the Python challenges →
Continue the courseCalculus Primer →
← Statistics & Probability Primer