Solution for the codewars challenge.
- Task description: https://www.codewars.com/kata/roman-numerals-decoder/python
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 digit and skipping any 0s. So 1990 is rendered "MCMXC" (1000 = M, 900 = CM, 90 = XC) and 2008 is rendered "MMVIII" (2000 = MM, 8 = VIII). The Roman numeral for 1666, "MDCLXVI", uses each letter in descending order.
solution('XXI') # should return 21
Tests are located in the tests
directory. To run Roman to decimal integer converter related tests use python -m unittest tests.test_roman_solution
- Denis Z. — Initial work — d2718nis
See also the list of contributors who participated in this project.
- Wikipedia: Roman numerals — the numeric system represented originated in ancient Rome
- Wikipedia: Arabic numerals — ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, based on the Hindu–Arabic numeral system