Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 143994

Submitted on 2 Oct 2012 by James

Correct

326Size
Leading solution size is 20.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = 'XIX';
y_correct = 19;
assert(isequal(roman(x),y_correct))
a =
   Empty matrix: 1-by-0
2
Pass
 
%%
x = 'IV MMXII LIV';
y_correct = [4 2012 54];
assert(isequal(roman(x),y_correct))
a =
     3     9
3
Pass
 
%%
x = 'MDCCCCX MCMIII MCMX';
y_correct = [1910 1903 1910];
assert(isequal(roman(x),y_correct))
a =
     8    15
4
Pass
 
%%
x = 'MDCCCCLXXXXVIIII MCMXCIX MIM';
y_correct = [1999 1999 1999];
assert(isequal(roman(x),y_correct))
a =
    17    25