Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Reverse Roman Numerals by takaki_1nj3ct0r
r2n = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
def reverse_roman(roman_string):
sum, prev = 0, 0
for x in [r2n[s] for s in roman_string[::-1]]:
if prev > x:
sum -= x
else:
sum += x
prev = x
return sum
Aug. 4, 2017