Convert a Roman numeral to a whole number. The symbols are I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000. Normally symbols are written from the largest to the smallest and added, but a smaller symbol before a bigger one is subtracted: IV = 4, IX = 9, XL = 40, XC = 90, CD = 400, CM = 900.
Example 1
Input:
roman_to_integer('III')
Output:
3
Three ones.
Example 2
Input:
roman_to_integer('MCMXCIV')
Output:
1994
1000 + 900 + 90 + 4 = 1994.
1 <= len(s) <= 15s is a valid Roman numeral (a number from 1 to 3999) made of the seven symbols.No results yet
Run your code to check it against the examples, or submit to run every test.