logo

Crowdly

Task 2 Roman numerals are represented by the following symbols: Usually a sm...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Task 2

Roman numerals are represented by the following symbols:

I1
V5
X10
L50
C100
D500
M1000

Usually a smaller value follows a larger one: VIII = 8XII = 12. However there are 6 cases where a smaller value is placed before a larger one - in that case it is subtracted:

  • IV = 4, IX = 9
  • XL = 40, XC = 90
  • CD = 400, CM = 900

Implement a function that converts a Roman numeral string to a decimal integer.

The input string is guaranteed to be a valid Roman numeral in the range [1, 3999].

More questions like this

Want instant access to all verified answers on courses.apriorit.com?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!