Cody

# Problem 2281. Array ex-OR

Solution 2474018

Submitted on 4 Jun 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 0 0 0 0 0 1 1 1 1 1 1; 0 0 0 1 1 1 0 0 0 1 1 1; 0 1 1 0 1 1 0 1 1 0 1 1; 0 1 0 1 0 1 0 1 0 1 0 1]; y = [0 0 1 0 0 1 1 1 0 1 1 0]; assert(isequal(arr_xor(x),y)) assert(isequal(arr_xor(x'),zeros(1,4)))

Output argument "out" (and maybe others) not assigned during call to "arr_xor". Error in Test1 (line 6) assert(isequal(arr_xor(x),y))

2   Fail
x = randi([0 1],4,12); y = x(1,:); for k=2:4 y = xor(y,x(k,:)); end assert(isequal(arr_xor(x),y))

Output argument "out" (and maybe others) not assigned during call to "arr_xor". Error in Test2 (line 6) assert(isequal(arr_xor(x),y))

3   Fail
% optional logical output try assert(islogical(arr_xor(randi([0 1],6,10)))) penalty = 0; catch disp('output is not logical, +15 points of penalty') penalty = 15; end % optional - dim x = randi([0 1],10); try assert(isequal(arr_xor(x),arr_xor(x ,1))) assert(isequal(arr_xor(x),arr_xor(x',2)')) catch disp('operating dimention not implemented. +15 points of penalty') penalty = penalty+15; end % optional - correct for singular dimention try assert(isequal(arr_xor(1),1)) assert(isequal(arr_xor([0 0 1 1 0]),0)) assert(isequal(arr_xor([0;1;1;1;0]),1)) catch disp('incorrect work for vectors, +10 points of penalty'); penalty=penalty+10; end % format conversion try assert(isequal(arr_xor(['MATLAB';'matlab']'),[0 0])) catch disp('no conversion from char, +2 points of penalty' ) penalty=penalty+2; end try assert(all(arr_xor(randi(5,5)))) assert(~any(arr_xor(randi(6,6)))) catch disp('no conversion from double, +5 points of penalty' ) penalty=penalty+5; end for l=1:4 stime(l)=tic; for k=2:750 [~]=arr_xor(randi([0 1],k)); end time(l)=toc(stime(l)); end time=min(time); disp(['elapsed time is ' num2str(time*1000) ' ms.']) %score calculation t = mtree('arr_xor.m','-file'); size = length(t.nodesize); feval(@assignin,'caller','score',size + penalty + round(time*5));

output is not logical, +15 points of penalty operating dimention not implemented. +15 points of penalty incorrect work for vectors, +10 points of penalty no conversion from char, +2 points of penalty no conversion from double, +5 points of penalty

Output argument "out" (and maybe others) not assigned during call to "arr_xor". Error in Test3 (line 44) [~]=arr_xor(randi([0 1],k));

### Community Treasure Hunt

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

Start Hunting!