0

Given:

{1,2,3}

Expected result:

{1,2,3},
{1,2},{1,3},{2,3},
{1},{2},{3}

So I want basically ALL possible combinations in a list ( but including all possible combinations of - when every element is removed ).

I hope you get what I mean ;)

Question: Which algorithm achieves this?

David
  • 2,551
  • 3
  • 34
  • 62

1 Answers1

4

You want the power set algorithm.

There are some examples on Rosetta Code.

  • You could at least copy-paste `C#` code from that site ... Otherwise it's more like a comment, not an answer. – MarcinJuraszek Apr 06 '13 at 16:49
  • @MarcinJuraszek Thanks for your comment, I was just about to start writing a **python** recursive function which does this... :D –  Apr 06 '13 at 16:50