Cody

Solution 1958666

Submitted on 4 Oct 2019 by Chul Min Yeum
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
n = 2; A = binary_numbers(n); assert(isequal(class(A), 'double'))

vec = '00' vec = '01' vec = '10' vec = '11' ans = 4

2   Pass
n = 3; A = binary_numbers(n); assert(all(A(:) == 0 | A(:) == 1))

vec = '000' vec = '001' vec = '010' vec = '011' vec = '100' vec = '101' vec = '110' vec = '111' ans = 8

3   Pass
n = 5; A = binary_numbers(n); assert(isequal(size(A),[32 5]))

vec = '00000' vec = '00001' vec = '00010' vec = '00011' vec = '00100' vec = '00101' vec = '00110' vec = '00111' vec = '01000' vec = '01001' vec = '01010' vec = '01011' vec = '01100' vec = '01101' vec = '01110' vec = '01111' vec = '10000' vec = '10001' vec = '10010' vec = '10011' vec = '10100' vec = '10101' vec = '10110' vec = '10111' vec = '11000' vec = '11001' vec = '11010' vec = '11011' vec = '11100' vec = '11101' vec = '11110' vec = '11111' ans = 32

4   Pass
n = 10; A = binary_numbers(n); assert(isequal(size(unique(A,'rows'),1),1024))

vec = '0000000000' vec = '0000000001' vec = '0000000010' vec = '0000000011' vec = '0000000100' vec = '0000000101' vec = '0000000110' vec = '0000000111' vec = '0000001000' vec = '0000001001' vec = '0000001010' vec = '0000001011' vec = '0000001100' vec = '0000001101' vec = '0000001110' vec = '0000001111' vec = '0000010000' vec = '0000010001' vec = '0000010010' vec = '0000010011' vec = '0000010100' vec = '0000010101' vec = '0000010110' vec = '0000010111' vec = '0000011000' vec = '0000011001' vec = '0000011010' vec = '0000011011' vec = '0000011100' vec = '0000011101' vec = '0000011110' vec = '0000011111' vec = '0000100000' vec = '0000100001' vec = '0000100010' vec = '0000100011' vec = '0000100100' vec = '0000100101' vec = '0000100110' vec = '0000100111' vec = '0000101000' vec = '0000101001' vec = '0000101010' vec = '0000101011' vec = '0000101100' vec = '0000101101' vec = '0000101110' vec = '0000101111' vec = '0000110000' vec = '0000110001' vec = '0000110010' vec = '0000110011' vec = '0000110100' vec = '0000110101' vec = '0000110110' vec = '0000110111' vec = '0000111000' vec = '0000111001' vec = '0000111010' vec = '0000111011' vec = '0000111100' vec = '0000111101' vec = '0000111110' vec = '0000111111' vec = '0001000000' vec = '0001000001' vec = '0001000010' vec = '0001000011' vec = '0001000100' vec = '0001000101' vec = '0001000110' vec = '0001000111' vec = '0001001000' vec = '0001001001' vec = '0001001010' vec = '0001001011' vec = '0001001100' vec = '0001001101' vec = '0001001110' vec = '0001001111' vec = '0001010000' vec = '0001010001' vec = '0001010010' vec = '0001010011' vec = '0001010100' vec = '0001010101' vec = '0001010110' vec = '0001010111' vec = '0001011000' vec = '0001011001' vec = '0001011010' vec = '0001011011' vec = '0001011100' vec = '0001011101' vec = '0001011110' vec = '0001011111' vec = '0001100000' vec = '0001100001' vec = '0001100010' vec = '0001100011' vec = '0001100100' vec = '0001100101' vec = '0001100110' vec = '0001100111' vec = '0001101000' vec = '0001101001' vec = '0001101010' vec = '0001101011' vec = '0001101100' vec = '0001101101' vec = '0001101110' vec = '0001101111' vec = '0001110000' vec = '0001110001' vec = '0001110010' vec = '0001110011' vec = '0001110100' vec = '0001110101' vec = '0001110110' vec = '0001110111' vec = '0001111000' vec = '0001111001' vec = '0001111010' vec = '0001111011' vec = '0001111100' vec = '0001111101' vec = '0001111110' vec = '0001111111' vec = '0010000000' vec = '0010000001' vec = '0010000010' vec = '0010000011' vec = '0010000100' vec = '0010000101' vec = '0010000110' vec = '0010000111' vec = '0010001000' vec = '0010001001' vec = '0010001010' vec = '0010001011' vec = '0010001100' vec = '0010001101' vec = '0010001110' vec = '0010001111' vec = '0010010000' vec = '0010010001' vec = '0010010010' vec = '0010010011' vec = '0010010100' vec = '0010010101' vec = '0010010110' vec = '0010010111' vec = '0010011000' vec = '0010011001' vec = '0010011010' vec = '0010011011' vec = '0010011100' vec = '0010011101' vec = '0010011110' vec = '0010011111' vec = '0010100000' vec = '0010100001' vec = '0010100010' vec = '0010100011' vec = '0010100100' vec = '0010100101' vec = '0010100110' vec = '0010100111' vec = '0010101000' vec = '0010101001' vec = '0010101010' vec = '0010101011' vec = '0010101100' vec = '0010101101' vec = '0010101110' vec = '0010101111' vec = '0010110000' vec = '0010110001' vec = '0010110010' vec = '0010110011' vec = '0010110100' vec = '0010110101' vec = '0010110110' vec = '0010110111' vec = '0010111000' vec = '0010111001' vec = '0010111010' vec = '0010111011' vec = '0010111100' vec = '0010111101' vec = '0010111110' vec = '0010111111' vec = '0011000000' vec = '0011000001' vec = '0011000010' vec = '0011000011' vec = '0011000100' vec = '0011000101' vec = '0011000110' vec = '0011000111' vec = '0011001000' vec = '0011001001' vec = '0011001010' vec = '0011001011' vec = '0011001100' vec = '0011001101' vec = '0011001110' vec = '0011001111' vec = '0011010000' vec = '0011010001' vec = '0011010010' vec = '0011010011' vec = '0011010100' vec = '0011010101' vec = '0011010110' vec = '0011010111' vec = '0011011000' vec = '0011011001' vec = '0011011010' vec = '0011011011' vec = '0011011100' vec = '0011011101' vec = '0011011110' vec = '0011011111' vec = '0011100000' vec = '0011100001' vec = '0011100010' vec = '0011100011' vec = '0011100100' vec = '0011100101' vec = '0011100110' vec = '0011100111' vec = '0011101000' vec = '0011101001' vec = '0011101010' vec = '0011101011' vec = '0011101100' vec = '0011101101' vec = '0011101110' vec = '0011101111' vec = '0011110000' vec = '0011110001' vec = '0011110010' vec = '0011110011' vec = '0011110100' vec = '0011110101' vec = '0011110110' vec = '0011110111' vec = '0011111000' vec = '0011111001' vec = '0011111010' vec = '0011111011' vec = '0011111100' vec = '0011111101' vec = '0011111110' vec = '0011111111' vec = '0100000000' vec = '0100000001' vec = '0100000010' vec = '0100000011' vec = '0100000100' vec = '0100000101' vec = '0100000110' vec = '0100000111' vec = '0100001000' vec = '0100001001' vec = '0100001010' vec = '0100001011' vec = '0100001100' vec = '0100001101' vec = '0100001110' vec = '0100001111' vec = '0100010000' vec = '0100010001' vec = '0100010010' vec = '0100010011' vec = '0100010100' vec = '0100010101' vec = '0100010110' vec = '0100010111' vec = '0100011000' vec = '0100011001' vec = '0100011010' vec = '0100011011' vec = '0100011100' vec = '0100011101' vec = '0100011110' vec = '0100011111' vec = '0100100000' vec = '0100100001' vec = '0100100010' vec = '0100100011' vec = '0100100100' vec = '0100100101' vec = '0100100110' vec = '0100100111' vec = '0100101000' vec = '0100101001' vec = '0100101010' vec = '0100101011' vec = '0100101100' vec = '0100101101' vec = '0100101110' vec = '0100101111' vec = '0100110000' vec = '0100110001' vec = '0100110010' vec = '0100110011' vec = '0100110100' vec = '0100110101' vec = '0100110110' vec = '0100110111' vec = '0100111000' vec = '0100111001' vec = '0100111010' vec = '0100111011' vec = '0100111100' vec = '0100111101' vec = '0100111110' vec = '0100111111' vec = '0101000000' vec = '0101000001' vec = '0101000010' vec = '0101000011' vec = '0101000100' vec = '0101000101' vec = '0101000110' vec = '0101000111' vec = '0101001000' vec = '0101001001' vec = '0101001010' vec = '0101001011' vec = '0101001100' vec = '0101001101' vec = '0101001110' vec = '0101001111' vec = '0101010000' vec = '0101010001' vec = '0101010010' vec = '0101010011' vec = '0101010100' vec = '0101010101' vec = '0101010110' vec = '0101010111' vec = '0101011000' vec = '0101011001' vec = '0101011010' vec = '0101011011' vec = '0101011100' vec = '0101011101' vec = '0101011110' vec = '0101011111' vec = '0101100000' vec = '0101100001' vec = '0101100010' vec = '0101100011' vec = '0101100100' vec = '0101100101' vec = '0101100110' vec = '0101100111' vec = '0101101000' vec = '0101101001' vec = '0101101010' vec = '0101101011' vec = '0101101100' vec = '0101101101' vec = '0101101110' vec = '0101101111' vec = '0101110000' vec = '0101110001' vec = '0101110010' vec = '0101110011' vec = '0101110100' vec = '0101110101' vec = '0101110110' vec = '0101110111' vec = '0101111000' vec = '0101111001' vec = '0101111010' vec = '0101111011' vec = '0101111100' vec = '0101111101' vec = '0101111110' vec = '0101111111' vec = '0110...

5   Pass
n = 1; A = binary_numbers(n); assert(isequal(A,[0;1]) || isequal(A,[1;0]))

vec = '0' vec = '1' ans = 2