Cody

Problem 302. Convert Roman to Arabic Numerals

Solution 53955

Submitted on 29 Feb 2012 by AMITAVA BISWAS
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))

t = XIX r = Empty string: 1-by-0

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

t = IV r = MMXII LIV t = MMXII r = LIV t = LIV r = Empty string: 1-by-0 h = 2012 54 h = 4 2012 54

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

t = MDCCCCX r = MCMIII MCMX t = MCMIII r = MCMX t = MCMX r = Empty string: 1-by-0 h = 1903 1910 h = 1910 1903 1910

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

t = MDCCCCLXXXXVIIII r = MCMXCIX MIM t = MCMXCIX r = MIM t = MIM r = Empty string: 1-by-0 h = 1999 1999 h = 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!