Cody

# Problem 1546. Create matrix with Gray code

Solution 2192153

Submitted on 4 Apr 2020
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
x = 0; y_correct = 1; y_correct(1) = []; assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))

ans = 0×1 empty double column vector

Output argument "g" (and maybe others) not assigned during call to "gray_code". Error in Test1 (line 4) assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))

2   Fail
x = 1; y_correct = [0;1]; assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))

ans = 0 1

Output argument "g" (and maybe others) not assigned during call to "gray_code". Error in Test2 (line 3) assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))

3   Fail
x = 2; y_correct = [0 0;0 1;1 1;1 0]; assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))

ans = 0 0 1 1 0 1 0 1

Output argument "g" (and maybe others) not assigned during call to "gray_code". Error in Test3 (line 3) assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))

4   Fail
x = 5; y_correct = [0 0 0 0 0;0 0 0 0 1;0 0 0 1 1;0 0 0 1 0;0 0 1 1 0;0 0 1 1 1 0 0 1 0 1;0 0 1 0 0;0 1 1 0 0;0 1 1 0 1;0 1 1 1 1;0 1 1 1 0;0 1 0 1 0 0 1 0 1 1;0 1 0 0 1;0 1 0 0 0;1 1 0 0 0;1 1 0 0 1;1 1 0 1 1;1 1 0 1 0 1 1 1 1 0;1 1 1 1 1;1 1 1 0 1;1 1 1 0 0;1 0 1 0 0;1 0 1 0 1;1 0 1 1 1 1 0 1 1 0;1 0 0 1 0;1 0 0 1 1;1 0 0 0 1;1 0 0 0 0]; assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))

ans = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 30 through 32 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1

Output argument "g" (and maybe others) not assigned during call to "gray_code". Error in Test4 (line 7) assert(isequal(gray_code(x),y_correct)&isequal(class(gray_code(x)),'double'))