🏂

Winter Olympics

Week 6

You are working for a local TV company in your country - with the Winter Olympics starting in 2 days this Friday, your company have given you the task of researching information about country's previous performance in time for the opening ceremony

They give you this historical Winter Olympic data and want you to output data for all countries separated by new line in the exact format shown below:

CountryX has won 426 medals from 1909 entries - a win rate of 22.32%. Their medal breakdown is 66 golds, 145 silvers and 215 bronzes. 322 men and 104 women have won medals - meaning 75.59% of medals have been won by men.

CountryY has won 1 medals from 31 entries - a win rate of 3.23%. Their medal breakdown is 1 golds, 0 silvers and 0 bronzes. 0 men and 1 women have won medals - meaning 0.00% of medals have been won by men.

CountryZ has won 0 medals from 116 entries - a win rate of 0.00%. Their medal breakdown is 0 golds, 0 silvers and 0 bronzes. 0 men and 0 women have won medals.

"CountryX", "CountryY" and "CountryZ" would obviously be the name of a valid country in the data

Your manager gives you a few extra hints:

  • Countries should be sorted firstly in descending order of total medals, then for any ties, in ascending order of total entries (e.g. there are two teams with 7 medals - one had 537 entries, the other had 598 entries. The team with 537 entries should be displayed first, since they have a higher win rate for the number of entries they made). If the countries are still tied, then sort alphabetically - i.e. Albania should come before Venezuela
  • Countries can have multiple entries in a single event - these might be listed as "Mexico-1" and "Mexico-2" for example. You should consider these as two entries in terms of the total entry count for the country of "Mexico"
  • All percentages should be output to 2 decimal places
  • You don't have to worry about correct plurality of words - e.g. you don't need to handle cases like "1 entries" being "1 entry"
  • If a country has won 0 medals like in the case of CountryZ, then note how the male medal percentage breakdown isn't included - this is because dividing by zero isn't defined - i.e. you don't need something like " - meaning 0.00% of medals have been won by men."
  • Since the exact format is required to get the correct answer, it's recommended you copy one of the examples when creating your output statement

If you want, there are also plenty of extension activities you can do as well - e.g. getting statistics by event/athlete/host city/country, finding the country with the most entries that has never won a medal etc - don't include any of this in your answer's output, it's just some possible extension ideas for anyone interested...

Hints

Hints will be released at the start of each of the following days - e.g. the start of day 3 is 48 hours after the challenge starts

Release Day Hint
2 Since the file is a csv, it's recommended to use a built-in/third party csv library to parse it and loop through the lines
3 You will probably want to create some kind of object/hashmap/dictionary/associative array (or whatever your language calls it) mapping the country name to the data - numbers of each type of medals, male & female medalist counts etc
5 To solve this, simply loop through all the file rows, adding countries to the hashmap if they don't already exist, update the relevant data, then finally sort the hashmap in descending order of total medal count
6 2026