Cody

Problem 302. Convert Roman to Arabic Numerals

Solution 1702915

Submitted on 5 Jan 2019 by Nikolaos Nikolaou
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))

tre = 10 -1 10 ii = 0 1 1 1 0 idx1 = 1 idx2 = 3 arabic = 19

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

tre = -1 5 0 1000 1000 10 1 1 0 50 -1 5 ii = 0 1 1 0 1 1 1 1 1 0 1 1 1 0 idx1 = 1 4 10 idx2 = 2 8 12 arabic = 4 2012 54

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

tre = Columns 1 through 14 1000 500 100 100 100 100 10 0 1000 -100 1000 1 1 1 Columns 15 through 19 0 1000 -100 1000 10 ii = 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 idx1 = 1 9 16 idx2 = 7 14 19 arabic = 1910 1903 1910

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

tre = Columns 1 through 14 1000 500 100 100 100 100 50 10 10 10 10 5 1 1 Columns 15 through 28 1 1 0 1000 -100 1000 -10 100 -1 10 0 1000 -1 1000 ii = Columns 1 through 29 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 Column 30 0 idx1 = 1 18 26 idx2 = 16 24 28 arabic = 1999 1999 1999

Suggested Problems

More from this Author39

Community Treasure Hunt

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

Start Hunting!