Re: subsets of a set
- To: mathgroup at smc.vnet.net
- Subject: [mg70033] Re: [mg70003] subsets of a set
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 1 Oct 2006 04:08:14 -0400 (EDT)
- Reply-to: hanlonr at cox.net
In version 5.1 or later use Subsets n=4; (Cases[Union[Union /@ Tuples[Range[n], n]], #1] & ) /@ Table[_, {i, n}, {j, i}]== Rest@Split[Subsets@Range[n], Length[#1]==Length[#2]&]== Split[Subsets[Range[n],{1,n}], Length[#1]==Length[#2]&] True Bob Hanlon ---- dimmechan at yahoo.com wrote: > Actually it was more easily than I believed > > lst=Tuples[Range[7], 3]; > Cases[Union[Union /@ lst], {_, _, _}] > {{1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 2, 6}, {1, 2, 7}, {1, 3, 4}, > {1,3, 5}, {1, 3, 6},{1, 3, 7}, {1, 4, 5}, {1, 4, 6}, {1, 4, 7}, > {1, 5, 6}, {1, 5, 7}, {1,6, 7}, {2, 3, 4},{2, 3, 5}, {2, 3, 6}, > {2, 3, 7}, {2, 4, 5}, {2, 4, 6}, {2, 4, 7}, {2,5, 6}, {2, 5, 7}, > {2, 6, 7}, {3, 4, 5}, {3, 4, 6}, {3, 4, 7}, {3, 5, 6}, {3, 5, 7}, > {3,6, 7}, {4, 5, 6},{4, 5, 7}, {4, 6, 7}, {5, 6, 7}} > > Anyway, I really appreciate your guidance for other approaches. > > BTW I discovered that (not big deal for you...but quite big for me!) > > Flatten[Outer[List, Range[7], Range[7], Range[7]], 2] == > Tuples[Range[7], 3] > True > > Also the following command gives all the sublsets of {1,2,3,4} > > (Cases[Union[Union /@ Tuples[Range[4], 4]], #1] & ) /@ > Table[_, {i, 1, 4}, {j, 1, i}] > {{{1}, {2}, {3}, {4}}, {{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, > {3, 4}}, {{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}}, > {{1, 2, 3, 4}}} > > Any other ideas to get the same output? > > Thanks in advance for any help. > > Dimitris Anagnostou >