Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
7-liner: based on best Roman Numerals solution solution in Clear category for Reverse Roman Numerals by przemyslaw.daniel
def reverse_roman(n):
result = 0
for roman, arabic in zip('CM CD XC XL IX IV M D C L X V I'.split(),
(900, 400, 90, 40, 9, 4, 1000, 500, 100, 50, 10, 5, 1)):
result += n.count(roman)*arabic
n = n.replace(roman, '')
return result
July 8, 2017
Comments: