Cody

# Problem 63. Encode Roman Numerals

Solution 1924800

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

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

Assertion failed.

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

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

Assertion failed.

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

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

Assertion failed.

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

t = 9 4 t1 = 2 s1 = 'IVXLCDM' l2 = 'IX' l3 = 'XL'

Index exceeds the number of array elements (2). Error in dec2rom (line 54) if t(3)==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' l2 = 'V' l3 = 'XL'

Index exceeds the number of array elements (2). Error in dec2rom (line 54) if t(3)==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' l2 = 0×0 empty char array

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