Re: find subsets
- To: mathgroup at smc.vnet.net
- Subject: [mg104756] Re: find subsets
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 8 Nov 2009 06:51:32 -0500 (EST)
On 11/7/09 at 6:47 AM, radford.schantz at mms.gov (r_poetic) wrote:
>First, generate a list of subsets using Subsets or KSubsets
>functions.
>Ns = KSubsets[{a,b,c,d,e},3] = {{a,b,c},{a,b,d},{a,b,e},{a,c,d},
>etc.}
>How can one infer from that list a list of its members that contain
>given elements, e.g. a list of members that contain b, or those that
>contain both b and c? For illustration:
>Some_function[Ns, b and c] = { {a,b,c},{b,c,d},{b,c,e}}
>I keep thinking there must be a direct way to do this using Select
>or some other function?
In[4]:= Cases[
Subsets[{a, b, c, d, e},
3], _?(Length[Intersection[#, {c, b}]] == 2 &)]
Out[4]= {{b,c},{a,b,c},{b,c,d},{b,c,e}}