Hi All,
I have question. Assume I have 9 digits, i,e, 1,2,...,9. I want 3 subsets such that each 3 digit number contains digits only ones. Ex: {123,456,789},{123,476,589}, {132,976,845},{321,786,594} so on. My attempt was.
n = FromDigits /@Permutations[Range@9, {3}]
Flatten[Table[{n[[i]], n[[j]], n[[k]]}, {i, Length@n}, {j,
Length@n}, {k, Length@n}], 2]
But this does not give me what I want.. My another try was:
In[64]:= n1 = FromDigits /@ Permutations[Range[1, 3], {3}]
Out[64]= {123, 132, 213, 231, 312, 321}
In[65]:= n2 = FromDigits /@ Permutations[Range[4, 6], {3}]
Out[65]= {456, 465, 546, 564, 645, 654}
In[66]:= n3 = FromDigits /@ Permutations[Range[7, 9], {3}]
Out[66]= {789, 798, 879, 897, 978, 987}
Flatten[Table[{n1[[i]], n2[[j]], n3[[k]]}, {i, Length@n1}, {j,
Length@n2}, {k, Length@n3}], 2]
This works but does not cover all permutations.. And I tried this one. But still no luck.
In[1]:= n1 = FromDigits /@ Permutations[{6, 2, 4}, {3}]
Out[1]={624, 642, 264, 246, 462, 426}
In[2]:= n2 = FromDigits /@ Permutations[{5, 7, 8}, {3}]
Out[2]= {578, 587, 758, 785, 857, 875}
In[3]:= n3 = FromDigits /@ Permutations[{3, 1, 9}, {3}]
Out[3]= {319, 391, 139, 193, 931, 913}
Flatten[Table[{n1[[i]], n2[[j]], n3[[k]]}, {i, Length@n1}, {j,
Length@n2}, {k, Length@n3}], 2]
Any suggestion? Thanks in advance..