Consider the code :
clear all
N = 7;
Set = 1:N;
for i = 1:N-1
Set1 = nchoosek(Set,i);
[ L_Set1 , C_Set1] = size(Set1);
A = zeros( L_Set1,N-C_Set1);
ASS_R7 = zeros( L_Set1 , N+1 );
for i1 = 1:L_Set1
A(i1,:) = setdiff( 1:N , Set1(i1,:) );
ASS_R7(i1,:) = [ Set1(i1,:), 0 ,A(i1,:) ];
end
ASS_R(i) = {ASS_R7};
end
Here, ASS_R gives all the possible [ (N-k) 0 k ] sets where the elements are unique (and belong to [1,7].Also k>0).
I have been trying to generalize this code for all N<=7 and have not been able to come up with a solution.
To be more clear: We get a cell array with cells of different sizes which look like this:
[ 1 2 3 4 5 6 0 7 ] . . . [ 1 0 2 3 4 5 6 7 ]
. .
{ . } . . . { . }
. .
[ 2 3 4 5 6 7 0 1 ] . . . [ 7 0 1 2 3 4 5 6 ]
However, I want all cells
[ 1 0 2 ] [ 1 0 2 3] [ 1 0 2 3 4 5 6 7 ]
. . .
{ . } . . { . } . . . { . }
. . .
[ 7 0 6 ] [ 7 0 6 5] [ 7 0 1 2 3 4 5 6 ]
[ 1 2 0 3 ] [ 1 2 0 3 4 5 6 7 ]
. .
{ . } . . . { . }
. .
[ 6 7 0 5 ] [ 6 7 0 1 2 3 4 5 ]
[ 1 2 3 4 5 6 0 7 ]
.
{ . }
.
[ 2 3 4 5 6 7 0 1 ]
Any ideas, guys?
'0'should be unique. Also, I don't want permutations like[ 1 2 0 3 ]and[ 2 1 0 3 ]. The 0 acts like a delimiter between two sets who have empty intersection.