Cody

Solution 1558713

Submitted on 12 Jun 2018 by Ryan Mitchell
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))

rem = 1990 Remainder: 1990 Checking: 1000 Current string: M Remainder: 990 Checking: 1000 Checking: 500 Current string: MC Remainder: 1090 Checking: 1000 Current string: MCM Remainder: 90 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Current string: MCMX Remainder: 100 Checking: 1000 Checking: 500 Checking: 100 Current string: MCMXC

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

rem = 2008 Remainder: 2008 Checking: 1000 Current string: M Remainder: 1008 Checking: 1000 Current string: MM Remainder: 8 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Current string: MMV Remainder: 3 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Checking: 1 Current string: MMVI Remainder: 2 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Checking: 1 Current string: MMVII Remainder: 1 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Checking: 1 Current string: MMVIII

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

rem = 1666 Remainder: 1666 Checking: 1000 Current string: M Remainder: 666 Checking: 1000 Checking: 500 Current string: MD Remainder: 166 Checking: 1000 Checking: 500 Checking: 100 Current string: MDC Remainder: 66 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Current string: MDCL Remainder: 16 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Current string: MDCLX Remainder: 6 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Current string: MDCLXV Remainder: 1 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Checking: 1 Current string: MDCLXVI

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

rem = 49 Remainder: 49 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Current string: X Remainder: 59 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Current string: XL Remainder: 9 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Current string: XLI Remainder: 10 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Current string: XLIX

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

rem = 45 Remainder: 45 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Current string: X Remainder: 55 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Current string: XL Remainder: 5 Checking: 1000 Checking: 500 Checking: 100 Checking: 50 Checking: 10 Checking: 5 Current string: XLV

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

rem = 0

Suggested Problems

More from this Author95