3 deleted 46 characters in body
source | link
g[l_, {n1_, n2_}] :=
  (sb = Subsets[l, {n1}];
  Flatten[
   Table[{i1 = sb[[i]], 
     i2 = Subsets[Delete[l, Partition[i1Subsets[Complement[l, 1]]i1], {n2}][[j]], 
     Delete[lComplement[l, Partition[Flatten[{i1, i2}], 1]]}, {j, 
     Length[l] - n1 - 1}, {i, 
     Length[sb]}], 1])
 
AbsoluteTiming[g[l, {2, 2}]]

0.000256

AbsoluteTiming[f[l, {2, 2, 1}]]

0.002062

g[l_, {n1_, n2_}] :=
  (sb = Subsets[l, {n1}];
  Flatten[
   Table[{i1 = sb[[i]], 
     i2 = Subsets[Delete[l, Partition[i1, 1]], {n2}][[j]], 
     Delete[l, Partition[Flatten[{i1, i2}], 1]]}, {j, 
     Length[l] - n1 - 1}, {i, Length[sb]}], 1])
 
AbsoluteTiming[g[l, {2, 2}]]

0.000256

AbsoluteTiming[f[l, {2, 2, 1}]]

0.002062

g[l_, {n1_, n2_}] := (sb = Subsets[l, {n1}];
  Flatten[
   Table[{i1 = sb[[i]], i2 = Subsets[Complement[l, i1], {n2}][[j]], 
     Complement[l, {i1, i2}]}, {j, Length[l] - n1 - 1}, {i, 
     Length[sb]}], 1])
AbsoluteTiming[g[l, {2, 2}]]

0.000256

AbsoluteTiming[f[l, {2, 2, 1}]]

0.002062

2 deleted 6 characters in body
source | link

This does the trick, however it is specific rather than generalised:

AbsoluteTiming[lg[l_, ={n1_, Range[5];n2_}] :=
 (sb = Subsets[l, {2n1}];
Flatten[Table[  Flatten[
   Table[{i1 = sb[[i]], 
     i2 = Subsets[Delete[l, Partition[i1, 1]], {2n2}][[j]], 
     Delete[l, Partition[Flatten[{i1, i2}], 1]]}, {j, 3
     Length[l] - n1 - 1}, {i, 
   Length[sb]}], 1]]1])

AbsoluteTiming[g[l, {2, 2}]]

0.000347000256

AbsoluteTiming[f[l, {2, 2, 1}]]

0.002062

This does the trick, however it is specific rather than generalised:

AbsoluteTiming[l = Range[5];
sb = Subsets[l, {2}];
Flatten[Table[{i1 = sb[[i]], 
   i2 = Subsets[Delete[l, Partition[i1, 1]], {2}][[j]], 
   Delete[l, Partition[Flatten[{i1, i2}], 1]]}, {j, 3}, {i, 
   Length[sb]}], 1]]

0.000347

AbsoluteTiming[f[l, {2, 2, 1}]]

0.002062

g[l_, {n1_, n2_}] :=
 (sb = Subsets[l, {n1}];
  Flatten[
   Table[{i1 = sb[[i]], 
     i2 = Subsets[Delete[l, Partition[i1, 1]], {n2}][[j]], 
     Delete[l, Partition[Flatten[{i1, i2}], 1]]}, {j, 
     Length[l] - n1 - 1}, {i, Length[sb]}], 1])

AbsoluteTiming[g[l, {2, 2}]]

0.000256

AbsoluteTiming[f[l, {2, 2, 1}]]

0.002062

    Post Undeleted by Feyre
    Post Deleted by Feyre
1
source | link

This does the trick, however it is specific rather than generalised:

AbsoluteTiming[l = Range[5];
sb = Subsets[l, {2}];
Flatten[Table[{i1 = sb[[i]], 
   i2 = Subsets[Delete[l, Partition[i1, 1]], {2}][[j]], 
   Delete[l, Partition[Flatten[{i1, i2}], 1]]}, {j, 3}, {i, 
   Length[sb]}], 1]]

0.000347

AbsoluteTiming[f[l, {2, 2, 1}]]

0.002062