Re: subsets of a set
- To: mathgroup at smc.vnet.net
- Subject: [mg70063] Re: [mg70001] subsets of a set
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sun, 1 Oct 2006 04:10:55 -0400 (EDT)
- References: <200609300912.FAA13086@smc.vnet.net>
On 30 Sep 2006, at 18:12, dimmechan at yahoo.com wrote: > In page 226 of John Gray's Mastering Mathematica > (unfortunately I had the 1994's edition) > there is the following exercise: > > "Given a finite set (presented as a list) and an integer k > find all k-element subsets of the set". > > There is one solution however for practicing (no there is no professor > that asked me this for homeworks! I work individually...) I search for > other > > So considering the following list > > lst = Tuples[Range[7], 3]; > > I can erase the sublists containg at least two same elements > > Cases[lst, {x_, y_, z_} /; x ß? y && x ß? z && y ß? z] > > but after I cannot erase the permutations of e.g. {1,2,3}; > that is in the output there are the sublists {1,2,3}, > {2,1,3},{3,1,2} e.t.c. for other triplets. > > I look for both functional as well pattern matching approaches. > > Thanks > Subsets[Range[7], {3}] ?? Andrzej Kozlowski