Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Reverse Roman Numerals by _Chico_
from collections import OrderedDict
Decimal_Roman = OrderedDict({'CM':900, 'CD':400, 'XC':90, 'XL':40, 'IX':9, 'IV':4, 'M':1000, 'D':500, 'C':100, 'L':50, 'X':10, 'V':5, 'I':1})
def reverse_roman(line):
result = 0
for key, value in Decimal_Roman.items():
result += (line.count(key) * value)
line = line.replace(key, '')
return result
July 10, 2021