β back to unit
Challenge
# puzzle gauntlet advanced
The School Fair Report
The fair is over; the money box holds a messy sales log. The principal wants a top-3 leaderboard. πͺ
You get the sales log as item:coins events (an item can appear many times β total them; at least 3 different items, all totals different). Print the top three earners, one per line, as <item> <total>, best first.
Example:
Input: sales = ["cake:5", "ring:3", "cake:2", "soda:4", "ring:9", "soda:1"]
Output:
ring 12
cake 7
soda 5
Totaling gives cake = 5+2 = 7, ring = 3+9 = 12, soda = 4+1 = 5 β sorted biggest first, ring leads.
π‘ need a hint?
pg-school-fair-report.pyπ given lines are locked β write your code in between
loading...