Cody

# Problem 63. Encode Roman Numerals

Solution 2083112

Submitted on 7 Jan 2020 by Malcolm Wildgoose
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))

n = 990 r = 'M' n = 90 r = 'MCM' n = 90 r = 'MCM' n = 90 r = 'MCM' n = 90 r = 'MCM' n = 0 r = 'MCMXC' n = 0 r = 'MCMXC' n = 0 r = 'MCMXC' n = 0 r = 'MCMXC' n = 0 r = 'MCMXC' n = 0 r = 'MCMXC' n = 0 r = 'MCMXC' n = 0 r = 'MCMXC'

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

n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 8 r = 'MM' n = 3 r = 'MMV' n = 3 r = 'MMV' n = 0 r = 'MMVIII'

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

n = 666 r = 'M' n = 666 r = 'M' n = 166 r = 'MD' n = 166 r = 'MD' n = 66 r = 'MDC' n = 66 r = 'MDC' n = 16 r = 'MDCL' n = 16 r = 'MDCL' n = 6 r = 'MDCLX' n = 6 r = 'MDCLX' n = 1 r = 'MDCLXV' n = 1 r = 'MDCLXV' n = 0 r = 'MDCLXVI'

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

n = 49 r = 0×0 empty char array n = 49 r = 0×0 empty char array n = 49 r = 0×0 empty char array n = 49 r = 0×0 empty char array n = 49 r = 0×0 empty char array n = 49 r = 0×0 empty char array n = 49 r = 0×0 empty char array n = 9 r = 'XL' n = 9 r = 'XL' n = 0 r = 'XLIX' n = 0 r = 'XLIX' n = 0 r = 'XLIX' n = 0 r = 'XLIX'

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

n = 45 r = 0×0 empty char array n = 45 r = 0×0 empty char array n = 45 r = 0×0 empty char array n = 45 r = 0×0 empty char array n = 45 r = 0×0 empty char array n = 45 r = 0×0 empty char array n = 45 r = 0×0 empty char array n = 5 r = 'XL' n = 5 r = 'XL' n = 5 r = 'XL' n = 0 r = 'XLV' n = 0 r = 'XLV' n = 0 r = 'XLV'

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

n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array n = 0 r = 0×0 empty char array

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!