Cody

# Problem 2045. Only once: cleaning up your columns

Solution 381447

Submitted on 8 Jan 2014 by Bernardo
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))

x = 1

2   Pass
%% x = [1 0 0 1]; y_correct = [1 0 0 1]; y = only_once(x); assert(isequal(y,y_correct))

x = 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))

x = 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)))

x = 1 0 0 1 1 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 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 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)))

x = Columns 1 through 16 1 1 1 0 1 1 0 0 0 0 1 1 1 1 1 0 Columns 17 through 32 1 0 1 0 1 0 0 1 0 0 0 0 1 1 1 0 Columns 33 through 48 0 1 0 0 0 1 1 1 1 1 0 0 1 0 0 1 Columns 49 through 64 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 Columns 65 through 80 0 0 0 1 1 1 1 1 0 1 0 0 1 0 0 1 Columns 81 through 96 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 Columns 97 through 100 0 0 0 1

6   Pass
%% x = randi(2,10,1)-1; y = only_once(x); assert(all(sum(y,1)==any(y,1)))

x = 1 0 0 0 0 0 0 0 0 0