Household Numbers: the Mathematics CapstoneHousehold Numbers
0 / 0

Workbench / Household Numbers: the Mathematics Capstone

S4 · B1·04

Unit Prices, Fair Shares and Goals

Stage 4, after chapter 4: which size of a product is really cheapest, compared exactly; a shared bill split into whole-paise shares that add up; and how many months a savings goal takes, with the last month's amount worked out, all with the division algorithm.

6 topics · ~5 min read
Updated Suggest a correction

Stage 4: unit prices, fair shares and goals

The brief

What you'll build. Three small tools for the household's money, each a direct use of chapter 4: a unit-price comparison across pack sizes, a fair split of shared bills into whole-paise shares, and a savings planner that says how many months a goal takes and how much the last month needs.

Why a real household needs this. "Bigger pack, better value" is usually true and sometimes not; shared bills among flatmates or family members cause arguments over a few paise when shares don't add up; and a goal ("₹2.5 lakh for a two-wheeler") is more real when you know it's 14 months, with ₹16,000 in the last one.

Why now. Chapter 4 gives exactly these operations: division as sharing and as grouping, the division algorithm with its remainder, and what the remainder means in each story.

What you'll have at the end. shares.py; a unit-price table for five things you buy often; one month of shared bills split; your own savings goal planned.

Theory to own

  1. Which division story? "Price per kilogram" is sharing (the price shared over the kilograms). "Months to save ₹2.5 lakh at ₹18,000 a month" is grouping. Why does one round down and the other round up? (Chapter: "What the remainder means".)
  2. Comparing without dividing. Why does comparing p1×g2 with p2×g1 tell you which pack is cheaper per gram, without computing either price per gram? (Exercises, C2.)
  3. Shares that add up. With a=qb+r, why do r shares of q+1 and b−r shares of q add up to exactly a? (Chapter: the division algorithm.)
  4. Rounding up with integers. Why is −(−a//b) the number of groups needed, for positive a and b? (Companion, "What the chapter oversimplifies", point 2.)

Build it

Step 1: by hand. Pick a product you buy in several sizes. Work out the price per kilogram (or litre) of each by long division to the paisa. Then work out how many months your own savings goal takes at what you can put aside, and what the last month needs.

Step 2: the code. All amounts in whole paise, every division with its remainder handled on purpose:

Python
"""Household numbers, stage 4: unit prices, fair splits and how long a goal takes, in whole paise."""
from math import gcd

def per_kg(price_paise, grams):
    """Price per kg in whole paise, and the remainder lost by rounding down (kept, so nothing is hidden)."""
    return divmod(price_paise * 1000, grams)

def cheapest(packs):
    """The pack with the lowest price per gram, compared exactly by cross-multiplying."""
    best = packs[0]
    for p in packs[1:]:
        if p[1] * best[2] < best[1] * p[2]:        # p.price / p.grams < best.price / best.grams
            best = p
    return best

rice = [("5 kg bag", 42500, 5000), ("10 kg bag", 81000, 10000), ("1 kg packet", 9200, 1000), ("26 kg sack", 210000, 26000)]
for name, price, g in rice:
    q, r = per_kg(price, g)
    print(f"{name:12} ₹{price / 100:>8.2f}  ->  ₹{q // 100}.{q % 100:02d} per kg" + (f" (+{r // gcd(r, g)}/{g // gcd(r, g)} of a paisa)" if r else ""))
print("cheapest per gram:", cheapest(rice)[0])

def split_equally(paise, people):
    """Whole-paise shares that add up exactly: the remainder goes one paisa at a time."""
    each, extra = divmod(paise, len(people))
    return {p: each + (1 if i < extra else 0) for i, p in enumerate(people)}

shares = split_equally(1_254_00 + 1, ["Kalpana", "Vikram", "Farah"])     # a ₹1,254.01 electricity bill
print(shares, "sum:", sum(shares.values()))

def months_to_save(target, monthly):
    """Grouping division, rounded up with integers: the last month may need less than a full saving."""
    if monthly <= 0:
        raise ValueError("saving nothing a month never reaches a target")
    months = -(-target // monthly)
    last = target - (months - 1) * monthly
    return months, last

m, last = months_to_save(2_50_000_00, 18_000_00)          # ₹2,50,000 at ₹18,000 a month
print(f"{m} months; the last month needs ₹{last // 100:,}")
Text
5 kg bag     ₹  425.00  ->  ₹85.00 per kg
10 kg bag    ₹  810.00  ->  ₹81.00 per kg
1 kg packet  ₹   92.00  ->  ₹92.00 per kg
26 kg sack   ₹ 2100.00  ->  ₹80.76 per kg (+12/13 of a paisa)
cheapest per gram: 26 kg sack
{'Kalpana': 41801, 'Vikram': 41800, 'Farah': 41800} sum: 125401
14 months; the last month needs ₹16,000

Step 3: read the output. The 26 kg sack is cheapest per gram, at ₹80.76 and twelve-thirteenths of a paisa per kilogram: the price per kg isn't a whole number of paise, so it's shown with its remainder rather than silently rounded. The comparison itself never divides, so two packs with equal unit prices can't look different because of rounding. The ₹1,254.01 bill splits into 41,801 + 41,800 + 41,800 paise, which add up exactly; the extra paisa goes to the first person, a rule you should state. The savings goal takes 14 months, the last needing only ₹16,000, because 2,50,000 =13×18,000+16,000.

Step 4: your numbers. Run it with your own products, bills and goal. Add a check that the cheapest pack is actually one you can store and use before it spoils: unit price is one consideration, not the decision.

Senior and architect lens

  • Name the rounding rule. Who gets the extra paisa, and whether a price is rounded down, up or to nearest, are business decisions. Write them in the code and in the user-facing text, so results can be explained and reproduced.
  • Compare exactly, display rounded. Comparisons use integer cross-multiplication; only the final display rounds. Mixing the two is how "₹80.77 per kg" and "₹80.76 per kg" end up describing the same price in two places.
  • Validate the inputs that make division meaningless. Zero grams, zero people and a monthly saving of zero are refused with a message, not turned into an infinite loop or a crash.

Evidence

  • shares.py with your products, bills and goal, and its output.
  • Your hand calculation of one unit price and one goal.
  • One sentence on a case where the cheapest unit price wasn't the right buy.

Carry forward

Stage 5, after chapter 5, schedules recurring payments (school fees every 3 months, insurance every 6, a subscription every 2) and finds when they land together, using lcm and gcd.