Cody

# Problem 1051. Exact binary matrix factorization

Solution 167731

Submitted on 25 Nov 2012
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
%% C = [1 1 1 0 0 0 0 0 0 1 0 1]; K = 2; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

2   Pass
%% C = [1 0 0 1 0 0 1 1 0]; K = 3; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

3   Pass
%% C = [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 1 0 0 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0 1 0 1 0 0 0 1 1 1 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]; K = 1; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B'),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

4   Pass
%% Added another small test case C = [1 0 1 1 1 1 0 1 0]; K = 2; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B'),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

5   Fail
%% A degenerate problem C = [0 0 1 0 0 0 0 0 1]; K = 2; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B'),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

Error: Assertion failed.