Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Camilla's team maintains an archaeology application used primarily by academics, researchers, and field guides. One window of the application displays a data grid of biographical
Camilla's team maintains an archaeology application used primarily by academics, researchers, and field guides. One window of the application displays a data grid of biographical information about various historical rulers along with archaeological data thereabout. Each ruler has a
regnal name, which is one or more "name parts" each separated by a single space followed by a Roman numeral. Examples of regnal names that may appear on this page are Pedro VII one "name part" and Alexander Pontus XV multiple "name parts" Note that the Roman numeral portion is always present, and it is always the last contiguous sequence of characters. Roman numerals are converted into decimal numerals using the standard procedure:
The letter represents V represents X represents L represents C represents D represents and M represents
When two letters appear next to one another and the first is the same as the second, or represents a larger decimal value that the second, the values are added; for example, the Roman numeral XV is When two letters appear next to one another and the first represents a smaller decimal value than the second, the value of the first is subtracted from the value of the second; for example, the Roman numeral IX is
As a larger example, the Roman numeral MMCDXLVIII is
Strings such as WXL which may be valid under "alternate" translation rules, are invalid Roman numerals under the standard translation procedure
Problem Statement
Assume that every regnal name contains a valid Roman numeral as its regnal number. Implement the following function in the code editor that sorts the rulers' names ascending, first by regnal number and then by casesensitive regnal name Assume that every regnal name contains a valid Roman numeral as its regnal number. Implement the following function in the code editor that sorts the rulers' names ascending, first by regnal number and then by
case
sensitive
regnal name.
aparam names The unordered collection of regnal names. A complete regnal name may appear more than once in the
collection
apre ap names is not empty.
areturns A new b
llection containing the same contents as ep name but in ascending sorted order, first by regnal
number and then by regnal name.Consider the list of rulers Nicholas VIII, Hypapsos XXIV, Garibald Yosef II Nicholas C Michelfranko XXIV
In decimal, Nicholas VIII translates into Nicholas
In decimal, Hypapsos XXIV translates into Hypapsos
In decimal, Garibald Yosef II translates into Garibald Yosef
In decimal, Nicholas C translates into Nicholas
In decimal, Michelfranko XXIV translates into Michelfranko
The function should therefore return Garibald Yosef II Nicholas VIII, Hypapsos XXIV, Michelfranko XXIV, Nicholas C
STDIN
names.size
Nichdas VIII
FUNCTION
names
Expect
Nicholas VIII, Hypapsos XXIV, Garibald Yosef II Nicholas C Michelfranko XXIV
Hypapsos XXIV
Garibald Yosef II
Nicholas C
Michelfranko XXIV
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started