A museum is cataloguing dates carved in Roman numerals:
| Symbol | I |
V |
X |
L |
C |
D |
M |
|---|---|---|---|---|---|---|---|
| Value | 1 | 5 | 10 | 50 | 100 | 500 | 1000 |
Symbols go largest first and add up (XVII = 17), except six subtracting pairs: IV = 4, IX = 9, XL = 40, XC = 90, CD = 400, CM = 900.
Write roman_value(s) -> int for a valid numeral from 1 to 3999.
roman_value("XVII") # 17
roman_value("XLIX") # 49
roman_value("MCMXCIV") # 1994
roman_value("MMMCMXCIX") # 3999
Show hint
compare each symbol with the one after it. What does a smaller left-hand symbol mean?