Function Kata "From Roman Numerals"

Write a function that uses Roman numerals [1] is translated into decimal numbers.

Examples:

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

The Roman numerals range from "I" to "MMM".

Assume that the Roman numerals are correct.

Variation

Recognize syntactic (e.g. "I X") and semantic (e.g. "IC") errors in Roman numerals.

Resources

[1] Roman numerals, http://de.wikipedia.org/wiki/R%C3%B6mische_Zahlschrift

Source

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

en_USEnglish