Cody

Solution 769201

Submitted on 30 Oct 2015 by Gustave Udahemuka
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))

LUT = [1000] 'M' [ 900] 'CM' [ 500] 'D' [ 400] 'CD' [ 100] 'C' [ 90] 'XC' [ 50] 'L' [ 40] 'XL' [ 10] 'X' [ 9] 'IX' [ 5] 'V' [ 4] 'IV' [ 1] 'I' romStr = M n = 990 romStr = MCM n = 90 romStr = MCMXC n = 0

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

LUT = [1000] 'M' [ 900] 'CM' [ 500] 'D' [ 400] 'CD' [ 100] 'C' [ 90] 'XC' [ 50] 'L' [ 40] 'XL' [ 10] 'X' [ 9] 'IX' [ 5] 'V' [ 4] 'IV' [ 1] 'I' romStr = M n = 1008 romStr = MM n = 8 romStr = MMV n = 3 romStr = MMVI n = 2 romStr = MMVII n = 1 romStr = MMVIII n = 0

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

LUT = [1000] 'M' [ 900] 'CM' [ 500] 'D' [ 400] 'CD' [ 100] 'C' [ 90] 'XC' [ 50] 'L' [ 40] 'XL' [ 10] 'X' [ 9] 'IX' [ 5] 'V' [ 4] 'IV' [ 1] 'I' romStr = M n = 666 romStr = MD n = 166 romStr = MDC n = 66 romStr = MDCL n = 16 romStr = MDCLX n = 6 romStr = MDCLXV n = 1 romStr = MDCLXVI n = 0

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

LUT = [1000] 'M' [ 900] 'CM' [ 500] 'D' [ 400] 'CD' [ 100] 'C' [ 90] 'XC' [ 50] 'L' [ 40] 'XL' [ 10] 'X' [ 9] 'IX' [ 5] 'V' [ 4] 'IV' [ 1] 'I' romStr = XL n = 9 romStr = XLIX n = 0

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

LUT = [1000] 'M' [ 900] 'CM' [ 500] 'D' [ 400] 'CD' [ 100] 'C' [ 90] 'XC' [ 50] 'L' [ 40] 'XL' [ 10] 'X' [ 9] 'IX' [ 5] 'V' [ 4] 'IV' [ 1] 'I' romStr = XL n = 5 romStr = XLV n = 0

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

LUT = [1000] 'M' [ 900] 'CM' [ 500] 'D' [ 400] 'CD' [ 100] 'C' [ 90] 'XC' [ 50] 'L' [ 40] 'XL' [ 10] 'X' [ 9] 'IX' [ 5] 'V' [ 4] 'IV' [ 1] 'I'