Cody

# Problem 302. Convert Roman to Arabic Numerals

Solution 517967

Submitted on 29 Oct 2014 by goc3
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))

r = XIX n = 10 1 10 nt = 19

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

r = IV n = 1 5 nt = 4 r = MMXII n = 1000 1000 10 1 1 nt = 4 2012 r = LIV n = 50 1 5 nt = 4 2012 54

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

r = MDCCCCX n = 1000 500 100 100 100 100 10 nt = 1910 r = MCMIII n = 1000 100 1000 1 1 1 nt = 1910 1903 r = MCMX n = 1000 100 1000 10 nt = 1910 1903 1910

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

r = MDCCCCLXXXXVIIII n = Columns 1 through 8 1000 500 100 100 100 100 50 10 Columns 9 through 16 10 10 10 5 1 1 1 1 nt = 1999 r = MCMXCIX n = 1000 100 1000 10 100 1 10 nt = 1999 1999 r = MIM n = 1000 1 1000 nt = 1999 1999 1999

### Community Treasure Hunt

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

Start Hunting!