Cody

# Problem 2045. Only once: cleaning up your columns

Solution 453906

Submitted on 12 Jun 2014 by rifat
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 = 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 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

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 1 0 1 1 1 1 0 1 0 0 1 1 Columns 17 through 32 0 1 1 1 1 1 1 0 0 1 0 0 0 1 1 1 Columns 33 through 48 0 0 1 0 0 1 0 1 1 1 0 1 1 1 1 1 Columns 49 through 64 0 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 Columns 65 through 80 0 0 1 0 0 0 0 0 0 1 1 0 1 0 0 1 Columns 81 through 96 1 0 1 0 1 1 1 1 1 0 0 1 0 0 1 1 Columns 97 through 100 1 0 0 0

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