# Return to Answer

 3 deleted 46 characters in body edited Aug 13 '16 at 14:58 Feyre 7,82722 gold badges2020 silver badges4343 bronze badges 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 edited Aug 13 '16 at 11:13 Feyre 7,82722 gold badges2020 silver badges4343 bronze badges This does the trick, however it is specific rather than generalised: AbsoluteTiming[lg[l_, ={n1_, Range;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; 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 occurred Aug 13 '16 at 11:05 Post Deleted by Feyre occurred Aug 13 '16 at 11:05 1 answered Aug 13 '16 at 11:03 Feyre 7,82722 gold badges2020 silver badges4343 bronze badges This does the trick, however it is specific rather than generalised: AbsoluteTiming[l = Range; 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