How to find all subsets which the total of elements is the same?

I want to find all subsets which the total of elements is the same.

For example, Subsets[Range[30], {5}] means all 5-element subsets and the range of each element is from 0 to 30. But I want to get the subsets which are only the total of elements equals to 30 (e.g., {6, 6, 6 ,6, 6}, {7, 5, 6, 6, 6}, ....

-

Select[Subsets[Range[30], {5}], Total[#] == 30 &]


Will give you the desired subsets.

Note that for this particular kind of problem

Sort[Sort /@ Select[IntegerPartitions[30, {5}], Unequal @@ # &]]


will give you the same results, much more quickly.

Note that your question is ambiguous: {6,6,6,6,6} is not a "subset" by definition.

If you meant partitions, the following will do it:

IntegerPartitions[30, {5}]

-
thanks a lot!!! –  Winnie Lee Feb 27 '14 at 12:31