NameSort
TCCC '03 NE/SE Regional · 2003-02-18 · by dgoodman
Problem Statement
Create a class NameSort that contains a method newList that
takes a
The names in the new sorted list should retain the same capitalization as they had in the original list.
Constraints
- list will contain between 1 and 50 elements, inclusive
- each element of list will contain between 1 and 20 characters, inclusive
- each character in each element of list will be a space, ' ', or a letter ('A'-'Z' or 'a'-'z')
- no element of list will contain leading or trailing spaces
- no element of list will contain two or more adjacent spaces
{"Tom Jones","ADAMS","BOB ADAMS",
"Tom Jones","STEVE jONeS"}
Returns: { "BOB ADAMS", "ADAMS", "STEVE jONeS", "Tom Jones", "Tom Jones" }
ADAMS comes before JONES. The ADAMS names are listed in reverse order as compared to the original list. Likewise for the JONES names.
{"C A R Hoare","Kenny G",
"A DeForest Hoar","Kenny Gee"}
Returns: { "Kenny G", "Kenny Gee", "A DeForest Hoar", "C A R Hoare" }
No two of these names have the same last name. So the final list is the case-insensitive alphabetically ordered by last name version of the original.
{"Trudy","Trudy","TRUDY"}
Returns: { "TRUDY", "Trudy", "Trudy" }
All three have the same last name. So they are sorted by importance, which corresponds to the reverse order as compared with the original list.
{"a b c d","A","Thomas a","d d",
"ed edgars","al Adams"}
Returns: { "Thomas a", "A", "al Adams", "d d", "a b c d", "ed edgars" }
{"TurnipHeadJohnson"}
Returns: { "TurnipHeadJohnson" }
Submissions are judged against all 29 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class NameSort with a public method vector<string> newList(vector<string> list) · 29 test cases · 2 s / 256 MB per case