Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<List<char>> Results(List<char> allValues)
- {
- var collection = new List<List<char>>();
- for (int counter = 0; counter < (1 << allValues.Count); ++counter)
- {
- List<char> combination = new List<char>();
- for (int i = 0; i < allValues.Count; ++i)
- {
- if ((counter & (1 << i)) == 0)
- combination.Add(allValues[i]);
- }
- // do something with combination
- collection.Add(combination);
- }
- return collection;
- }
- void PowerSetofChars()
- {
- var chars = new List<char> { 'A', 'B', 'C' };
- var result = Results(chars);
- }
Add Comment
Please, Sign In to add comment