Cody

# Problem 2281. Array ex-OR

Solution 3114551

Submitted on 8 Oct 2020 by Nikolaos Nikolaou
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   Pass
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)))

out = 0 0 1 0 0 1 1 1 0 1 1 0 out = 0 0 0 0

2   Pass
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))

out = 1 1 1 0 1 0 0 0 1 0 0 1

3   Pass
% 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));

out = 1 1 0 1 0 0 0 1 0 0 output is not logical, +15 points of penalty out = 1 1 0 0 0 0 0 1 0 0 out = 1 1 0 0 0 0 0 1 0 0 out = 1 1 0 0 0 0 0 1 0 0 out = 0 0 0 0 0 1 0 1 0 1 operating dimention not implemented. +15 points of penalty out = 1 out = 0 0 1 1 0 incorrect work for vectors, +10 points of penalty out = 0 0 out = 1 1 1 1 1 out = 0 0 0 0 0 0 out = 0 0 out = 0 0 1 out = 1 0 1 1 out = 0 0 1 1 1 out = 0 1 1 0 0 0 out = 1 0 1 1 1 1 0 out = 0 0 0 1 1 1 0 0 out = 0 0 1 1 0 0 0 0 1 out = 0 0 0 0 0 1 0 1 0 0 out = 1 1 0 1 1 1 0 0 0 0 0 out = 1 1 0 1 0 1 0 1 1 0 1 0 out = 1 0 1 1 1 0 1 1 0 0 0 0 1 out = 1 1 0 0 1 0 1 0 1 1 1 0 1 1 out = 1 1 0 0 0 1 0 0 1 1 0 0 1 1 0 out = 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 1 out = 0 0 0 1 1 0 0 1 0 1 1 0 0 1 0 0 1 out = 0 0 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 1 out = 1 1 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 out = 0 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 0 1 1 1 out = 0 0 1 1 1 1 0 1 1 0 0 0 1 0 0 0 1 1 0 1 0 out = 1 1 1 1 0 1 1 0 0 0 1 1 0 1 1 1 0 1 0 1 1 0 out = 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 1 1 0 0 0 1 1 1 out = 1 0 1 1 1 0 0 1 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 1 out = 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 1 1 1 0 1 1 0 1 0 0 out = 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 out = 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0 out = 0 1 1 1 0 1 1 1 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 out = 1 1 1 0 0 0 0 1 0 0 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 1 1 1 out = Columns 1 through 29 1 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 Column 30 1 out = Columns 1 through 29 1 1 0 1 1 1 1 1 0 0 1 1 0 0 1 1 1 0 1 0 0 0 1 1 0 1 0 1 0 Columns 30 through 31 1 0 out = Columns 1 through 29 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 0 1 Columns 30 through 32 1 1 1 out = Columns 1 through 29 1 1 0 0 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 Columns 30 through 33 0 1 0 0 out = Columns 1 through 29 1 0 0 0 1 0 1 0 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 Columns 30 through 34 0 1 1 0 1 out = Columns 1 through 29 0 1 1 1 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 1 0 1 1 Columns 30 through 35 0 1 1 1 1 1 out = Columns 1 through 29 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 0 0 1 1 0 Columns 30 through 36 1 1 0 1 0 0 1 out = Columns 1 through 29 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 1 0 0 0 1 0 1 1 Columns 30 through 37 1 1 1 1 1 0 0 1 out = Columns 1 through 29 0 1 0 0 0 1 1 0 0 1 0 0 1 0 1 0 0 0 0 0 0 1 1 0 1 1 1 1 0 Columns 30 through 38 1 1 1 0 1 0 0 1 1 out = Columns 1 through 29 1 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 1 1 0 1 0 0 0 1 0 1 0 0 0 Columns 30 through 39 0 1 0 0 1 1 1 0 1 0 out = Columns 1 through 29 0 1 1 0 0 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 1 0 Columns 30 through 40 1 1 0 0 0 1 0 0 1 0 0 out = Columns 1 through 29 0 0 1 0 1 0 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 Columns 30 through 41 0 1 0 1 1 0 0 1 1 1 0 0 out = Columns 1 through 29 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 Columns 30 through 42 1 1 0 1 1 0 1 0 0 1 0 0 1 out = Columns 1 through 29 0 0 0 1 1 1 1 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1 1 Columns 30 through 43 1 0 0 0 0 0 1 0 1 1 0 0 1 1 out = Columns 1 through 29 0 0 0 1 0 1 1 1 1 1 0 0 0 1 0 0 0 1 0 1 0 1 1 1 1 1 1 1 1 Columns 30 through 44 1 0 1 0 1 1 1 0 1 0 0 1 0 0 0 out = Columns 1 through 29 0 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 1 1 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 1 1 0 0 0 0 0 0 1 0 1 1 1 out = Columns 1 through 29 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 0 1 1 0 1 0 Columns 30 through 46 0 0 1 0 1 0 1 1 0 1 0 1 1 0 0 0 1 out = Columns 1 through 29 1 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 1 1 Columns 30 through 47 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 0 1 1 out = Columns 1 through 29 0 0 1 0 1 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 0 1 1 0 Columns 30 through 48 1 0 1 0 1 0 1 1 0 0 0 1 0 0 1 1 0 0 1 out = Columns 1 through 29 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 0 1 1 0 1 Columns 30 through 49 0 1 0 0 1 1 0 1 0 0 1 0 1 0 0 1 1 0 0 1 out = Columns 1 through 29 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 1 Columns 30 through 50 1 0 0 1 1 1 0 0 0 0 1 1 1 0 0 1 0 1 0 1 1 out = Columns 1 through 29 1 0 0 1 0 0 0 0 1 1 0 0 0 1 1 1 0 0...

### Community Treasure Hunt

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

Start Hunting!