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 186827

Submitted on 6 Jan 2013 by @bmtran

Correct

23Size
Leading solution size is 18.
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 true false false true false true];
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
clear g A;
assert(isequal(solver(f),false))

                    
2
Pass
 
%%
A=[false true false true false];
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
clear g A;
assert(isequal(solver(f),true))

                    
3
Pass
 
%%
A=[false false true true true];
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
clear g A;
assert(isequal(solver(f),false))

                    
4
Pass
 
%%
A=[true false false true false false true true true];
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
clear g A;
assert(isequal(solver(f),false))

                    
5
Pass
 
%%
A=rand(1,99)<.5;
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
assert(isequal(solver(f),mean(A)<.5))

                    
6
Pass
 
%%
A=rand(1,99)<.5;
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
assert(isequal(solver(f),mean(A)<.5))

                    
7
Pass
 
%%
A=rand(1,99)<.5;
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
assert(isequal(solver(f),mean(A)<.5))

                    
8
Pass
 
%%
A=rand(1,99)<.5;
g=inline('logical(interp1([0,1],[0,x],1))','x','A');
f=arrayfun(@(x)@(str)xor(~x,g(eval(str),A)),A,'uni',0);
assert(isequal(solver(f),mean(A)<.5))