Product revenue share
Your task
Marketing wants each product's share of revenue as a whole-number percentage. Each row is "product,amount" with a POSITIVE integer amount; a product may appear on many rows, and there is at least one row. Return a dictionary mapping each product to floor(100 * product_total / grand_total). Shares may not add up to exactly 100 because of flooring, that is expected. Example: ["mug,30", "tee,50", "mug,20"] gives {"mug": 50, "tee": 50}.
Examples
revenue_share(rows: list[str]) -> dict[str,int]Example 1
Input
revenue_share(["mug,30", "tee,50", "mug,20"])Output
{"mug": 50, "tee": 50}