I do not know anything about Roman Numerals and I have a problem that request code for it. I'm sure what this is asking me to do.
Consider Roman numerals: different letters have numeric values, which are added or subtracted depending on their position. Remember that I, V, X, L, C, D, and M represent, respective, 1, 5, 10, 50, 100, 500, and 1000. (One mnemonic device for remembering this is the sentence "If Victor's Xray Looks Clear, Don't Medicate.") Thus, in Roman numerals, "LIX" would be 59, because you add 50 to (10 - 1).
We're going to do a simplified version of this: in our version, instead of position indicating whether you add or subtract, we're going to use case. In our system, UPPER-CASE LETTERS are positive, and lower-case letters are negative. Thus, in our system, to write 59, you could use "LiX", or "LXi", or any other combination of L, X, and i.
Any letter or symbol not in the set {I, V, X, L, C, D, M, i, v, x, l, c, d, m} is simply ignored. Thus, "Mommy" gives the value -1000, because there is one positive thousand (M), and two negative thousands (mm). The o, and the y, have no value and are ignored. "Midway" gives 499, because there is one positive thousand (M), one negative 500 (d), and one negative 1 (i). The other letters are ignored. `villi' gives -107. `MCMLXXI' is 2171, because we add all the values. (In actual Roman numerals, that would give 1971, because the `CM' means to subtract 100 from the 1000.) You may or may not find it useful to be reminded that Mid(foo, n, 1) returns the nth character of the string foo.
Start Free Trial