Count and total · Medium
Top three products
Each line is a product and the units sold in one order: "<Product>, <units>". Products repeat across orders.
Task
Write a prompt that lists the three best-selling products by total units.
Output format
<1st>,<2nd>,<3rd>
- Highest first.
- If totals tie, order those products alphabetically.
- If there are fewer than three products, list all of them.
Your prompt must contain {input}: it is replaced by each test case, just like the hidden tests in a hiring test.
Sample case 1
Input
Pen, 5 Book, 3 Pen, 2 Bag, 4 Cup, 1
Output
Pen,Bag,Book
Sample case 2
Input
Lamp, 2 Desk, 2 Chair, 2 Rug, 1
Output
Chair,Desk,Lamp
There are 4 test cases in all; the others are like hidden tests: work out what tricky inputs they might use!