Cody

Solution 2071090

Submitted on 27 Dec 2019 by Asif Newaz
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 = 1; y_correct = 1; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = '1' b = 1

2   Pass
x = 1:8; y_correct = [1 10 11 100 101 110 111 1000]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = 8×4 char array '0001' '0010' '0011' '0100' '0101' '0110' '0111' '1000' b = 1 10 11 100 101 110 111 1000

3   Pass
x = 8:20; y_correct = [1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 10010 10011 10100]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = 13×5 char array '01000' '01001' '01010' '01011' '01100' '01101' '01110' '01111' '10000' '10001' '10010' '10011' '10100' b = 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 10010 10011 10100

4   Pass
x = 1:2:21; y_correct = [1 11 101 111 1001 1011 1101 1111 10001 10011 10101]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = 11×5 char array '00001' '00011' '00101' '00111' '01001' '01011' '01101' '01111' '10001' '10011' '10101' b = 1 11 101 111 1001 1011 1101 1111 10001 10011 10101

5   Pass
x = 2.^(0:10); y_correct = [1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = 11×11 char array '00000000001' '00000000010' '00000000100' '00000001000' '00000010000' '00000100000' '00001000000' '00010000000' '00100000000' '01000000000' '10000000000' b = 1.0e+10 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000

6   Pass
x = 2.^(1:10) - 1; y_correct = [1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = 10×10 char array '0000000001' '0000000011' '0000000111' '0000001111' '0000011111' '0000111111' '0001111111' '0011111111' '0111111111' '1111111111' b = 1.0e+09 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0011 0.0111 0.1111 1.1111

7   Pass
x = 2:2:20; y_correct = [10 100 110 1000 1010 1100 1110 10000 10010 10100]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = 10×5 char array '00010' '00100' '00110' '01000' '01010' '01100' '01110' '10000' '10010' '10100' b = 10 100 110 1000 1010 1100 1110 10000 10010 10100

8   Pass
x = 42; y_correct = 101010; assert(sum(abs(Converter(x)-y_correct))<1e-3)

a = '101010' b = 101010