Ralph, I am not sure if you know this trick or not, but if you start with
interger (n) whose binary representation contains exactly k ones then
{ int t,b;
 t=n^(n&(n-1));
 b=t+n;
 n=b|(((b^n)/t)>>2);
}
generates next larger number with exactly k ones. As long as you stay within int size (in your case with 28 elements you do) it is a decent method.

_________________________________________________________________
Puzzles, trivia teasers, word scrambles and more. Play for your chance to win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to