Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 257842

Submitted on 7 Jun 2013 by Matt

Correct

20Size
Leading solution size is 13.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
A=true; B=false; X=1;
f=inline('logical(interp1([0,1],[0,x],1))','x','A','B','X');
fA=@(str)xor(~A,f(eval(str),A,B,X));
fB=@(str)xor(~B,f(eval(str),A,B,X));
clear f A B X;
assert(isequal(solver(fA,fB),1))
correct_road =
     1
2
Pass
 
%%
A=true; B=false; X=2;
f=inline('logical(interp1([0,1],[0,x],1))','x','A','B','X');
fA=@(str)xor(~A,f(eval(str),A,B,X));
fB=@(str)xor(~B,f(eval(str),A,B,X));
clear f A B X;
assert(isequal(solver(fA,fB),2))
correct_road =
     2
3
Pass
 
%%
A=false; B=true; X=1;
f=inline('logical(interp1([0,1],[0,x],1))','x','A','B','X');
fA=@(str)xor(~A,f(eval(str),A,B,X));
fB=@(str)xor(~B,f(eval(str),A,B,X));
clear f A B X;
assert(isequal(solver(fA,fB),1))
correct_road =
     1
4
Pass
 
%%
A=false; B=true; X=2;
f=inline('logical(interp1([0,1],[0,x],1))','x','A','B','X');
fA=@(str)xor(~A,f(eval(str),A,B,X));
fB=@(str)xor(~B,f(eval(str),A,B,X));
clear f A B X;
assert(isequal(solver(fA,fB),2))
correct_road =
     2