Cody

# Problem 63. Encode Roman Numerals

Solution 1924807

Submitted on 7 Sep 2019
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 = 1990; y_correct = 'MCMXC'; assert(isequal(dec2rom(x),y_correct))

t = 0 9 9 1 t1 = 4 s1 = 'IVXLCDM' l1 = 'M' l2 = 0×0 empty char array l3 = 'XC' l4 = 'CM' romStr = 'MCMXC'

2   Pass
x = 2008; y_correct = 'MMVIII'; assert(isequal(dec2rom(x),y_correct))

t = 8 0 0 2 t1 = 4 s1 = 'IVXLCDM' l1 = 'MM' l2 = 'VIII' l3 = 0×0 empty char array l4 = 0×0 empty char array romStr = 'MMVIII'

3   Pass
x = 1666; y_correct = 'MDCLXVI'; assert(isequal(dec2rom(x),y_correct))

t = 6 6 6 1 t1 = 4 s1 = 'IVXLCDM' l1 = 'M' l2 = 'VI' l3 = 'LX' l4 = 'DC' romStr = 'MDCLXVI'

4   Fail
x = 49; y_correct = 'XLIX'; assert(isequal(dec2rom(x),y_correct))

t = 9 4 t1 = 2 s1 = 'IVXLCDM'

Index exceeds the number of array elements (2). Error in dec2rom (line 6) if t(4)==1 Error in Test4 (line 3) assert(isequal(dec2rom(x),y_correct))

5   Fail
x = 45; y_correct = 'XLV'; assert(isequal(dec2rom(x),y_correct))

t = 5 4 t1 = 2 s1 = 'IVXLCDM'

Index exceeds the number of array elements (2). Error in dec2rom (line 6) if t(4)==1 Error in Test5 (line 3) assert(isequal(dec2rom(x),y_correct))

6   Fail
x = 0; y_correct = ''; assert(isempty(dec2rom(x)))

t = 0 t1 = 1 s1 = 'IVXLCDM'

Index exceeds the number of array elements (1). Error in dec2rom (line 6) if t(4)==1 Error in Test6 (line 3) assert(isempty(dec2rom(x)))