How many full batches fit a pan

Food and flavour

A round pan of 24 units seen from above, filled from the centre with two full batches of 2, 3 and 5 parts. Each unit is a ring of equal area holding one grain for every cent it costs. Turmeric marks the four units of room left at the rim.

Integer parts are weighed into the largest number of full batches that fit a pan, and the remainder is what does not fit.

Each line also carries a cost per unit of weight, so the desk counts what one batch, the placed blend and one unit of blend cost, in whole cents.

A pan of 24 units holding two batches of 2, 3, and 5 parts, with 4 units left over.
The default pan of 24 units, drawn to scale. Two full batches of 2, 3, and 5 parts fill 20 units; the dashed 4 units at the end are the remainder.

Two to four parts, each an integer from 0 to 200, with at least one positive part. Pan capacity is an integer from 0 to 2000. A part is an unnamed unit. Each cost is a whole number of cents per unit from 0 to 10000, in the order of the parts.

The result appears here when the page script runs.

How it is computed

Method

Let the parts sum to T. The batch count is the greatest integer B with B times T at most the pan. Placed units are B times each part. The remainder is pan minus the placed total. Shares are the reduced ratios of the parts over T. The weighing step is the gcd of the parts.

A line costs its parts times its cents per unit; one batch costs the sum over the lines, and the placed blend costs that sum times the batch count, checked against the line-by-line total. One unit of blend costs the batch cost over T, kept as a reduced fraction of a cent, and its nearest cent rounds a half upward. Every amount is a whole number of cents, so no money passes through floating point.

Assumptions

A part is an unnamed unit. Mixing is ideal. Order is the order typed. A zero batch is a defined result: nothing was placed, and the remainder is the pan.

Limits

A line is an unnamed unit, so the result is arithmetic rather than a recipe, a supplier quote, a nutrition figure, or a safety limit. The remainder carries no cost because it is not placed.

Reproducibility

The inputs are kept in the address bar, so the same link reruns the same calculation. An address without costs takes the default costs in order.