MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

subsets of a set

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70003] subsets of a set
  • From: dimmechan at yahoo.com
  • Date: Sat, 30 Sep 2006 05:12:27 -0400 (EDT)

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


  • Prev by Date: RE: How to make a progress bar?
  • Next by Date: Re: Re: mapping of function
  • Previous by thread: subsets of a set
  • Next by thread: general