Cody

# Problem 63. Encode Roman Numerals

Solution 412545

Submitted on 3 Mar 2014 by Axel
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))

d = Columns 1 through 8 1000 900 500 400 100 90 50 40 Columns 9 through 13 10 9 5 4 1 r = 'M' 'CM' 'D' 'CD' 'C' 'XC' 'L' 'XL' 'X' 'IX' 'V' 'IV' 'I' ans = []

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

d = Columns 1 through 8 1000 900 500 400 100 90 50 40 Columns 9 through 13 10 9 5 4 1 r = 'M' 'CM' 'D' 'CD' 'C' 'XC' 'L' 'XL' 'X' 'IX' 'V' 'IV' 'I' ans = []

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

d = Columns 1 through 8 1000 900 500 400 100 90 50 40 Columns 9 through 13 10 9 5 4 1 r = 'M' 'CM' 'D' 'CD' 'C' 'XC' 'L' 'XL' 'X' 'IX' 'V' 'IV' 'I' ans = []

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

d = Columns 1 through 8 1000 900 500 400 100 90 50 40 Columns 9 through 13 10 9 5 4 1 r = 'M' 'CM' 'D' 'CD' 'C' 'XC' 'L' 'XL' 'X' 'IX' 'V' 'IV' 'I' ans = []

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

d = Columns 1 through 8 1000 900 500 400 100 90 50 40 Columns 9 through 13 10 9 5 4 1 r = 'M' 'CM' 'D' 'CD' 'C' 'XC' 'L' 'XL' 'X' 'IX' 'V' 'IV' 'I' ans = []

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

d = Columns 1 through 8 1000 900 500 400 100 90 50 40 Columns 9 through 13 10 9 5 4 1 r = 'M' 'CM' 'D' 'CD' 'C' 'XC' 'L' 'XL' 'X' 'IX' 'V' 'IV' 'I' ans = []