But if I have 14 1s in a string of length 28? Mind you I haven't looked closely at Rogers next mail which talks about cobination undex


On Mon, 27 Aug 2007, Roger Hui wrote:

There are k!n binary strings of length n with k 1s,
and (i.n) e."1 k comb n are all such strings. e.g.

  4 comb 6
0 1 2 3
0 1 2 4
0 1 2 5
0 1 3 4
0 1 3 5
0 1 4 5
0 2 3 4
0 2 3 5
0 2 4 5
0 3 4 5
1 2 3 4
1 2 3 5
1 2 4 5
1 3 4 5
2 3 4 5
  (i.6) e."1 ]4 comb 6
1 1 1 1 0 0
1 1 1 0 1 0
1 1 1 0 0 1
1 1 0 1 1 0
1 1 0 1 0 1
1 1 0 0 1 1
1 0 1 1 1 0
1 0 1 1 0 1
1 0 1 0 1 1
1 0 0 1 1 1
0 1 1 1 1 0
0 1 1 1 0 1
0 1 1 0 1 1
0 1 0 1 1 1
0 0 1 1 1 1

See:

http://www.jsoftware.com/jwiki/Essays/Combinations
http://www.jsoftware.com/jwiki/Essays/Combination_Index



----- Original Message -----
From: Ralph G Selfridge <[EMAIL PROTECTED]>
Date: Monday, August 27, 2007 13:24
Subject: [Jprogramming] Permutations of a sort.
To: [email protected]

Here's my problem. I have a binary string, potentially long, in
my case
28. I need to get all binary strings with a specified number of
1s. I doubt
I can get them all at once, too many, so how do I get from one
to the next?

What next means is irrelvant, just so I get them with no
duplicates if I
run long emough.

While I have an answer, I'm curious to see if there is a better way.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to