Cody

Solution 2023806

Submitted on 16 Nov 2019 at 0:57
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
dec = [12345.12345,9876.9876]; x = 16; y_correct={'3039.1f9a6b50b','2694.fcd35a8588'}; assert(isequal(dec2basex(dec,x),y_correct))

base = 0×0 empty cell array

Error using dec2base (line 22) First argument must be an array of integers, 0 <= D <= flintmax. Error in dec2basex (line 4) base(end+1) = num2str(dec2base(val,x)) Error in Test1 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

2   Fail
dec = [12345.12345,9876.9876]; x = 7; y_correct={'50664.0602255245326442','40536.6625141031624663'}; assert(isequal(dec2basex(dec,x),y_correct))

base = 0×0 empty cell array

Error using dec2base (line 22) First argument must be an array of integers, 0 <= D <= flintmax. Error in dec2basex (line 4) base(end+1) = num2str(dec2base(val,x)) Error in Test2 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

3   Fail
dec= [9626.150562201365,389979.4884571975,981037227081.0962,15.15348748187026,2951227.338373619,409,667123.807,30421.507,7285.4,38.59]; x=2; y_correct={'10010110011010.0010011010001011','1011111001101011011.0111110100001011','1110010001101010011000000001110001001001.00011000101','1111.001001110100101','1011010000100000111011.0101011010011111','110011001','10100010110111110011.1100111010010111','111011011010101.100000011100101','1110001110101.011001100110011','100110.100101110000101'}; assert(isequal(dec2basex(dec,x),y_correct))

base = 0×0 empty cell array

Error using dec2base (line 22) First argument must be an array of integers, 0 <= D <= flintmax. Error in dec2basex (line 4) base(end+1) = num2str(dec2base(val,x)) Error in Test3 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

4   Fail
dec= [9626.150562201365,389979.4884571975,981037227081.0962,15.15348748187026,2951227.338373619,409,667123.807,30421.507,7285.4,38.59]; x=15; y_correct={'2cbb.23d2328955460e16','7a839.74d822b72acb9542','1a7bbad1da6.1699a53843c6d265','10.24804853517ecc5e','3d4687.51202701347ad6c6','1c4','d29ed.c18959596b861b57','9031.7911d1d1d2a6d883','225a.6','28.8cb3b3b3b3b3b3b3'}; assert(isequal(dec2basex(dec,x),y_correct))

base = 0×0 empty cell array

Error using dec2base (line 22) First argument must be an array of integers, 0 <= D <= flintmax. Error in dec2basex (line 4) base(end+1) = num2str(dec2base(val,x)) Error in Test4 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

5   Fail
dec= [9626.150562201365,389979.4884571975,981037227081.0962,15.15348748187026,2951227.338373619,409,667123.807,30421.507,7285.4,38.59]; x=12; y_correct={'56a2.1982083a8431a88a','169823.5a407946253a442','13a16b470949.11a276','13.1a12871b92951307','ba3a77.40886226776a669','2a1','282097.9825b510827439','15731.610119a7a57a6104','4271.4972497249724972','32.70b62a68781b0591'}; assert(isequal(dec2basex(dec,x),y_correct))

base = 0×0 empty cell array

Error using dec2base (line 22) First argument must be an array of integers, 0 <= D <= flintmax. Error in dec2basex (line 4) base(end+1) = num2str(dec2base(val,x)) Error in Test5 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

6   Fail
dec=0.173; x=11; y_correct={'0.19a2990645a78076'}; assert(isequal(dec2basex(dec,x),y_correct))

base = 0×0 empty cell array

Error using dec2base (line 22) First argument must be an array of integers, 0 <= D <= flintmax. Error in dec2basex (line 4) base(end+1) = num2str(dec2base(val,x)) Error in Test6 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

7   Fail
dec=0; x=3; y_correct={'0'}; assert(isequal(dec2basex(dec,x),y_correct))

base = 0×0 empty cell array

Conversion to cell from char is not possible. Error in dec2basex (line 4) base(end+1) = num2str(dec2base(val,x)) Error in Test7 (line 4) assert(isequal(dec2basex(dec,x),y_correct))