Back to Practice
#0124

Mixture Average Price

MediumAptitude25 min20 XP

Problem

A shop mixes 10 kg rice at 40 per kg with 15 kg rice at 60 per kg. Find average price per kg.

Why This Matters

Mixture questions become simple once you track total cost and total quantity.

Examples

Example 1
Input10 kg at 40, 15 kg at 60
Output52 per kg

Average price is total cost divided by total quantity.

Constraints

  • Return the requested value exactly.
  • Handle the stated edge cases.
  • Keep the solution readable.
CodeReasoning
A shop mixes 10 kg rice at 40 per kg with 15 kg rice at 60 per kg. Find average price per kg.
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Input10 kg at 40, 15 kg at 60
Expected52 per kg

Average price is total cost divided by total quantity.

Hidden Test Categories
equal quantitiesthree mixturestarget average