From Roman Numerals

Function Kata „From Roman Numerals“

Implement a function that maps roman numerals to decimals.

Examples:

  • „I“ -> 1
  • „II“ -> 2
  • „IV“ -> 4
  • „V“ -> 5
  • „IX“ -> 9
  • „XLII“ -> 42
  • „XCIX“ -> 99
  • „MMXIII“ -> 2013

Roman numerals are defined in the range of „I“ to „MMM“.

Roman digitIVXLCDM
Decimal values1510501005001000

Consider the input as correct.

Variation

Detect syntactic (e.g. „I X“) and semantic (e.g. „IC“) errors in roman numerals.

Resources

[1] Roman numerals, https://en.wikipedia.org/wiki/Roman_numerals

Source

http://codingdojo.org/cgi-bin/wiki.pl?KataRomanNumerals