Problem 52188. Roman numbers: how old is that building?
The front of old buildings sometimes show the year when they were built in roman numbers. These number are rather confusing and not easy to understand, Can you make a program that can translate any string with any roman number between 0 to 3999 back a decimal number? (an empty string should return zero).
I found this even more challenging than the reverse problem (problem 63 Encode Roman numbers) which I liked a lot and was obviously the inspiration of this problem.
Examples:
- 'XXIII' should return 23 (XX=20 III=3)
- 'MMXXI' should return 2021 (MM=2000 XX=20 I=1)
- 'MDCLXVI' should return 1666 (MDC =1600 LX=60 VI=6)
- 'CMXCIX' should return 999 (CM=900,XC=90,IX=9)
- '' (empty string) should return 0
Only integer numbers between 0 and 3999 can be handled.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers14
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
50019 Solvers
-
3333 Solvers
-
Remove the polynomials that have positive real elements of their roots.
1703 Solvers
-
828 Solvers
-
9415 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!