Cody

# Problem 2876. Convert number from given base to other base

Solution 1653112

Submitted on 19 Oct 2018
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
n = 400; b=5; rb=8; y_correct = 144; assert(isequal(base_base(n,b,rb),y_correct))

Error using base2dec>base2decImpl (line 58) 'N' contains characters which cannot be converted to base 5. Error in base2dec (line 26) dec = base2decImpl(str,base); Error in base_base (line 5) x=base2dec('n',b); Error in Test1 (line 5) assert(isequal(base_base(n,b,rb),y_correct))

2   Fail
n = 200; b=8; rb=5; y_correct = 1003; assert(isequal(base_base(n,b,rb),y_correct))

Error using base2dec>base2decImpl (line 58) 'N' contains characters which cannot be converted to base 8. Error in base2dec (line 26) dec = base2decImpl(str,base); Error in base_base (line 5) x=base2dec('n',b); Error in Test2 (line 5) assert(isequal(base_base(n,b,rb),y_correct))

3   Fail
n = 125; b=6; rb=7; y_correct = 104; assert(isequal(base_base(n,b,rb),y_correct))

Error using base2dec>base2decImpl (line 58) 'N' contains characters which cannot be converted to base 6. Error in base2dec (line 26) dec = base2decImpl(str,base); Error in base_base (line 5) x=base2dec('n',b); Error in Test3 (line 5) assert(isequal(base_base(n,b,rb),y_correct))

4   Fail
n = 143; b=8; rb=4; y_correct = 1203; assert(isequal(base_base(n,b,rb),y_correct))

Error using base2dec>base2decImpl (line 58) 'N' contains characters which cannot be converted to base 8. Error in base2dec (line 26) dec = base2decImpl(str,base); Error in base_base (line 5) x=base2dec('n',b); Error in Test4 (line 5) assert(isequal(base_base(n,b,rb),y_correct))