Cody

Problem 195. Program an exclusive OR operation with logical operators

Solution 2761381

Submitted on 30 Jul 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
a=0;b=0; res=0; assert(isequal(myXOR(a,b),res))

Assertion failed.

2   Fail
a=1;b=1; res=0; assert(isequal(myXOR(a,b),res))

Assertion failed.

3   Pass
a=1;b=0; res=1; assert(isequal(myXOR(a,b),res))

4   Pass
a=0;b=1; res=1; assert(isequal(myXOR(a,b),res))

5   Fail
a=[0 0 1 1];b=[1 0 1 0]; res=[1 0 0 1]; assert(isequal(myXOR(a,b),res))

Operands to the || and && operators must be convertible to logical scalar values. Error in myXOR (line 2) y= ~a || ~b && a || b; Error in Test5 (line 3) assert(isequal(myXOR(a,b),res))

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!