Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I need a program about all of partitions from set
example:
set:{1,2,3}
all of partitions:
1.{{1},{2},{3}}
2.{{1,2},{3}}
3.{{1},{2,3}}
4.{{1,3},{2}}
Posted
Comments
Sergey Alexandrovich Kryukov 1-Dec-11 2:28am    
Not a question.
--SA
Sergey Alexandrovich Kryukov 1-Dec-11 2:29am    
Also, the problem is not fully formulated. And this is too simple. You need to show what have you done.
--SA
OriginalGriff 1-Dec-11 3:06am    
What have you tried so far? Anything?
[no name] 1-Dec-11 4:20am    
*Sigh* The homework assignments just don't get any more interesting. If I were him, I would quickly learn how to [hint]climb a tree[/hint].
Richard MacCutchan 1-Dec-11 5:30am    
Can you serve fries from a tree?

1 solution

NN: "not diffrenet between {{2},{2,3}} and {{1,3},{2}}"

I think you made a typing error here when you wrote "{{2},{2,3}}. But, at least you are making a first step towards precisely stating your requirements. You have just specified that each permutation that includes two elements is a 'true' set: which means {1,3} and {3,1} are equivalent ... this requirement, for example, I believe (but am not totally sure) would rule out using the 'Distinct operator in Linq.

CodeProject is your friend: "Permutations, Combinations, and Variations using C# Generics" by Adrian Akison"[^] !

And this blog post by Eric Lippert, "Computing a Cartesian Product with LINQ"[^], may be helpful.

Next: show us some code, whether you Linq, or opt for other types of composition :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900