Task

Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer.

You don't need to validate the form of the Roman numeral.

Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately,

starting with the leftmost decimal digit and skipping any 0s   (zeroes).

1990 is rendered as   MCMXC     (1000 = M,   900 = CM,   90 = XC)     and

2008 is rendered as   MMVIII       (2000 = MM,   8 = VIII).

The Roman numeral for 1666,   MDCLXVI,   uses each letter in descending order.




function RomanNumeralsDecode numerals
	put {
		"M": 1000,
		"D": 500,
		"C": 100,
		"L": 50,
		"X": 10,
		"V": 5,
		"I": 1
	} into values
 
	put 0 into total
	repeat with each character letter of numerals
		if values.(character the counter + 1 of numerals) is less than or equal to values.(letter) 
			add values.(letter) to total
		else
			subtract values.(letter) from total
		end if
	end repeat
	return total
end RomanNumeralsDecode