Cody

Solution 369743

Submitted on 13 Dec 2013 by Michael C.
  • Size: 15
  • This is the leading solution.
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 = 1; y_correct = 1; y = only_once(x); assert(isequal(y,y_correct))
ans = 1
2   Pass
%% x = [1 0 0 1]; y_correct = [1 0 0 1]; y = only_once(x); assert(isequal(y,y_correct))
ans = 1 0 0 1
3   Pass
%% x = [0 0 1 1 0;0 1 1 0 0;0 0 0 0 1]; y_correct = [0 0 1 1 0;0 1 0 0 0;0 0 0 0 1]; y = only_once(x); assert(isequal(y,y_correct))
ans = 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1
4   Pass
%% x = randi(2,10,10)-1; y = only_once(x); assert(all(sum(y,1)==any(y,1)))
ans = 0 0 0 1 0 1 1 1 0 1 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5   Pass
%% x = randi(2,1,100)-1; y = only_once(x); assert(all(sum(y,1)==any(y,1)))
ans = Columns 1 through 16 1 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 Columns 17 through 32 1 0 0 1 1 0 0 1 1 1 1 1 0 1 0 0 Columns 33 through 48 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 Columns 49 through 64 0 1 0 1 1 0 1 1 1 1 0 1 0 0 1 1 Columns 65 through 80 1 1 1 0 0 0 1 1 0 1 1 1 1 0 0 0 Columns 81 through 96 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 1 Columns 97 through 100 1 1 1 1
6   Pass
%% x = randi(2,10,1)-1; y = only_once(x); assert(all(sum(y,1)==any(y,1)))
ans = 1 0 0 0 0 0 0 0 0 0