You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In grade school the container is chosen to be map<int, vector<string>> a better choice would be std::set<string> or std::multiset<string> instead of vector, because the list of students needs to stay sorted.
I see two ways to fix this:
Change the tests to expect a std::set or std::mutliset
Change the tests accept any type of container, as long as it compiles. We can do this using the std::result_of trait.
The second approach gives a student more room to play with things, while it can make it harder to understand what fails to compile/what the tests actually check. It will also require a better testing framework, as we would want to test a few examples.
Look, what a quick reply! (Sorry for the long wait.)
I am with you that the exercise would be neater with a multiset. It would also be nice to accept multiple containers to do the trick.
On the other hand, students can see the tests and should use them as their guidance on how to solve the exercise. So they already know tit's a map of vectors with an int key. It is quite easy to grasp from other languages, and there is no secret they have to figure out, and be stunned when it is not a set.
I like your solution for the "accept all of them", but reading the test becomes a lot trickier for (new) learners and is therefore more of a hurdle. The well-versed students, who know of multisets, will probably not be as versed in how traits are used. I think it would be better to have an exercise that teaches multisets and/or traits, than to shove it into this (easy) beginner's exercise.
Is that okay for you, or do you see some argument I might miss out on?
Activity
vaeng commentedon Sep 28, 2026
Look, what a quick reply! (Sorry for the long wait.)
I am with you that the exercise would be neater with a multiset. It would also be nice to accept multiple containers to do the trick.
On the other hand, students can see the tests and should use them as their guidance on how to solve the exercise. So they already know tit's a map of vectors with an int key. It is quite easy to grasp from other languages, and there is no secret they have to figure out, and be stunned when it is not a set.
I like your solution for the "accept all of them", but reading the test becomes a lot trickier for (new) learners and is therefore more of a hurdle. The well-versed students, who know of multisets, will probably not be as versed in how traits are used. I think it would be better to have an exercise that teaches multisets and/or traits, than to shove it into this (easy) beginner's exercise.
Is that okay for you, or do you see some argument I might miss out on?