Kodewick
Start learning →
Mini challenge←→0 / 60

Jump rope medals

#058Mini challengeMapsLoops6 min

At the jump rope contest, skips is how many jumps each person did in a minute. 100 or more wins "gold", 80 or more "silver", 60 or more "bronze", and under 60 gets no medal. Fill in the loop to count how many of each medal were given; a medal nobody won doesn't appear.

Examples
medals({120, 85, 61, 30})→{'bronze': 1, 'gold': 1, 'silver': 1}
medals({})→{}
The functionmap<string, int> medals(const vector<int> &skips)
main.cpp
#include <map>
#include <string>
#include <vector>
using namespace std;

map<string, int> medals(const vector<int> &skips) {
    map<string, int> count;
    for (int s : skips) {
        // your code here: find s's medal and add 1 to it
    }
    return count;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.