• Teaser Home

    Clean Code Developer School

    Saubere Softwareentwicklung üben – regelmäßig, fokussiert, individuell, angeleitet

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 digit I V X L C D M
Decimal values 1 5 10 50 100 500 1000

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