1.
int const SIZE = 20;
int const MAX_MASK = (1 << 20);
FOR (set, MAX_MASK) {
  int a = amount of 1's in the set;
  if (a == SIZE / 2) print set;
}

2. int current = (1 << 10) - 1; // set is AAAA...ABBBB...BBB
int max = (1 << 20) - 1 - current;
while (current != LARGE) {
print set;
current = next smallest number with the same number of 1's
}

3. recursive solution

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to