0
$\begingroup$

Please consider:

list1={0,0,0,0,0,0};
list2={1,1,1,1,1,1};

How can I access to the result of

Permutations[Flatten[{list1, list2}]]
(* {{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, 
 {0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1}, 
 {0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}, 
  {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1}, and so on*)

But by Tuples?

$\endgroup$
0
2
$\begingroup$

Not very efficient but straightforward

list1={0,0,0,0,0,0};
list2={1,1,1,1,1,1};
perm=Sort[Permutations[Flatten[{list1,list2}]]];
tupl=Sort[Select[Tuples[{0,1},12],Count[#,0]==6&]];
perm==tupl

True

$\endgroup$
3
  • $\begingroup$ It is good but I think because the code has to compute all elements in the Tuples[{0,1},12] and after that considers to Count it takes long for longer lists?! $\endgroup$ – Inzo Babaria Jul 24 '17 at 9:32
  • $\begingroup$ @InzoBabaria that's why I said "Not very efficient". $\endgroup$ – Vitaliy Kaurov Jul 24 '17 at 9:37
  • $\begingroup$ Ok thank you so much. $\endgroup$ – Inzo Babaria Jul 24 '17 at 9:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.