- First convert the integer to it's equivalent Roman Numeral.
- Then convert each capital letter of that Roman Numeral to their ASCII/UNICODE decimal value.
- And output the sum of those.
1991 -> MCMXCI -> 77+67+77+88+67+73 -> 449 ^ input ^ output
Here is a perhaps useful Roman Numeral Converter.
- Standard Roman Numeral rules are applied, so no alternative forms like
- The Macron lines above the Roman Numerals past 1,000 are
¯(UNICODE nr. 175). So one line counts as
+175and two as
- You are allowed to use any kind of input and output type, as long as it represents the integers.
- The test cases will be in the range of
1 - 2,147,483,647.
* Roman Numeral rules (quote from Wikipedia):
Numbers are formed by combining symbols and adding the values, so
IIis two (two ones) and
XIIIis thirteen (a ten and three ones). Because each numeral has a fixed value rather than representing multiples of ten, one hundred and so on, according to position, there is no need for "place keeping" zeros, as in numbers like 207 or 1066; those numbers are written as
CCVII(two hundreds, a five and two ones) and
MLXVI(a thousand, a fifty, a ten, a five and a one).
Symbols are placed from left to right in order of value, starting with the largest. However, in a few specific cases, to avoid four characters being repeated in succession (such as
XXXX), subtractive notation is often used as follows:
Xindicates one less, so four is
IV(one less than five) and nine is
IX(one less than ten)
Cindicates ten less, so forty is
XL(ten less than fifty) and ninety is
XC(ten less than a hundred)
Mindicates a hundred less, so four hundred is
CD(a hundred less than five hundred) and nine hundred is
CM(a hundred less than a thousand)
MCMIVis one thousand nine hundred and four, 1904 (
Mis a thousand,
CMis nine hundred and
Some examples of the modern use of Roman numerals include:
MCMLIV; 1990 as
MCMXC; 2014 as
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
- Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
100 -> 67 1 -> 73 4 -> 159 22 -> 322 5000 -> 261 2016 -> 401 1000000000 -> 427 1991 -> 449 9999 -> 800 1111111111 -> 2344 2147483647 -> 5362