Cody

Problem 2202. Flip the bit

Solution 2032720

Submitted on 23 Nov 2019
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
s = '1001'; y_correct = '0110'; assert(all(isequal(flipbit(s),y_correct)&ischar(flipbit(s))))

a = 1 a = 1 0 a = 1 0 0 a = 1 0 0 1 y = 1×4 logical array 0 1 1 0 y1 = '0 1 1 0' a = 1 a = 1 0 a = 1 0 0 a = 1 0 0 1 y = 1×4 logical array 0 1 1 0 y1 = '0 1 1 0'

Assertion failed.

2   Fail
s = '11'; y_correct = '00'; assert(all(isequal(flipbit(s),y_correct)&ischar(flipbit(s))))

a = 1 a = 1 1 y = 1×2 logical array 0 0 y1 = '0 0' a = 1 a = 1 1 y = 1×2 logical array 0 0 y1 = '0 0'

Assertion failed.

3   Fail
s = '1'; y_correct = '0'; assert(all(isequal(flipbit(s),y_correct)&ischar(flipbit(s))))

a = 1 y = logical 0 y1 = '0' a = 1 y = logical 0 y1 = '0'

Assertion failed.

4   Fail
s = '100000001'; y_correct = '011111110'; assert(all(isequal(flipbit(s),y_correct)&ischar(flipbit(s))))

a = 1 a = 1 0 a = 1 0 0 a = 1 0 0 0 a = 1 0 0 0 0 a = 1 0 0 0 0 0 a = 1 0 0 0 0 0 0 a = 1 0 0 0 0 0 0 0 a = 1 0 0 0 0 0 0 0 1 y = 1×9 logical array 0 1 1 1 1 1 1 1 0 y1 = '0 1 1 1 1 1 1 1 0' a = 1 a = 1 0 a = 1 0 0 a = 1 0 0 0 a = 1 0 0 0 0 a = 1 0 0 0 0 0 a = 1 0 0 0 0 0 0 a = 1 0 0 0 0 0 0 0 a = 1 0 0 0 0 0 0 0 1 y = 1×9 logical array 0 1 1 1 1 1 1 1 0 y1 = '0 1 1 1 1 1 1 1 0'

Assertion failed.

5   Fail
s = '00001'; y_correct = '11110'; assert(all(isequal(flipbit(s),y_correct)&ischar(flipbit(s))))

a = 0 a = 0 0 a = 0 0 0 a = 0 0 0 0 a = 0 0 0 0 1 y = 1×5 logical array 1 1 1 1 0 y1 = '1 1 1 1 0' a = 0 a = 0 0 a = 0 0 0 a = 0 0 0 0 a = 0 0 0 0 1 y = 1×5 logical array 1 1 1 1 0 y1 = '1 1 1 1 0'

Assertion failed.