Cody

# Problem 302. Convert Roman to Arabic Numerals

Solution 2542017

Submitted on 13 Jun 2020 by jmac
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 'XIX'; y_correct = 19; assert(isequal(roman(x),y_correct))

w = 10 y = 10 w = 1 y = 9 w = 10 y = 19

2   Pass
x = 'IV MMXII LIV'; y_correct = [4 2012 54]; assert(isequal(roman(x),y_correct))

w = 5 y = 5 w = 1 y = 4 w = 50 y = 54 z = 0 w = 1 y = 1 54 w = 1 y = 2 54 w = 10 y = 12 54 w = 1000 y = 1012 54 w = 1000 y = 2012 54 z = 0 w = 5 y = 5 2012 54 w = 1 y = 4 2012 54

3   Pass
x = 'MDCCCCX MCMIII MCMX'; y_correct = [1910 1903 1910]; assert(isequal(roman(x),y_correct))

w = 10 y = 10 w = 1000 y = 1010 w = 100 y = 910 w = 1000 y = 1910 z = 0 w = 1 y = 1 1910 w = 1 y = 2 1910 w = 1 y = 3 1910 w = 1000 y = 1003 1910 w = 100 y = 903 1910 w = 1000 y = 1903 1910 z = 0 w = 10 y = 10 1903 1910 w = 100 y = 110 1903 1910 w = 100 y = 210 1903 1910 w = 100 y = 310 1903 1910 w = 100 y = 410 1903 1910 w = 500 y = 910 1903 1910 w = 1000 y = 1910 1903 1910

4   Pass
x = 'MDCCCCLXXXXVIIII MCMXCIX MIM'; y_correct = [1999 1999 1999]; assert(isequal(roman(x),y_correct))

w = 1000 y = 1000 w = 1 y = 999 w = 1000 y = 1999 z = 0 w = 10 y = 10 1999 w = 1 y = 9 1999 w = 100 y = 109 1999 w = 10 y = 99 1999 w = 1000 y = 1099 1999 w = 100 y = 999 1999 w = 1000 y = 1999 1999 z = 0 w = 1 y = 1 1999 1999 w = 1 y = 2 1999 1999 w = 1 y = 3 1999 1999 w = 1 y = 4 1999 1999 w = 5 y = 9 1999 1999 w = 10 y = 19 1999 1999 w = 10 y = 29 1999 1999 w = 10 y = 39 1999 1999 w = 10 y = 49 1999 1999 w = 50 y = 99 1999 1999 w = 100 y = 199 1999 1999 w = 100 y = 299 1999 1999 w = 100 y = 399 1999 1999 w = 100 y = 499 1999 1999 w = 500 y = 999 1999 1999 w = 1000 y = 1999 1999 1999

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!