Count and total · Medium

Top sales region

A sales sheet has one line per sale: the region, a colon, and the amount. Region names may be typed in different capitals, and amounts may have a $ sign or commas.

Task

Write a prompt that finds the region with the highest total sales.

Output format

<Region>:<Total with 2 decimals>

  • Write the region with a capital first letter (North, not north).
  • If two regions tie, give the one that comes first in alphabetical order.

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
North: 1200
South: 800
North: 300
Output
North:1500.00
Sample case 2
Input
east: $1,250.50
West: 900
EAST: 49.50
Output
East:1300.00

There are 5 test cases in all; the others are like hidden tests: work out what tricky inputs they might use!

Loading the editor…