I have a set, lets say: set = {1, 2, 3, 4, 5}
I want to get all the possible subsets with 1, 2, and 2 elements.
What I did was to generate all possible permutations (5!) of set and use TakeList
:
allofthem = TakeList[#, {2, 2, 1}] & /@ Permutations[set]
Afterwards, I had to order them (at level 2) and use DeleteDuplicates
:
DeleteDuplicates[
Table[Map[Sort, allofthem[[i]]], {i, 1, Length[allofthem]}]]
I would like to do this in a simpler way, perhaps avoiding the use of Table
Any help would be appreciated.
TakeList
? AFAIK that is not a built-in Mathematica function. $\endgroup$Subsets[]
already? $\endgroup$TakeList
was introduced in MMA 11.2 $\endgroup$Tuples[Range[5], 1]
andTuples[Range[5],2]
? $\endgroup$