Roger's method is undoubtedly better but is something like this suitable?

   ri=. 28?~&.>1000$4
   3{.ri
+----------------------------+
¦22 1 4 7¦2 27 11 8¦27 26 8 3¦
+----------------------------+
   putin1s=: 4 : '1 x}y'
NB. Why doesn't something like this work:
NB. rs=. (1) ri}&><bs
NB. ?
   $rs=. ri putin1s&><28$0
1000 28
   4*./ . =+/"1 rs
1
   $~.rs
984 28
NB. 984 unique

NB. Could also do this (slightyly faster):
   $rs2=. (1) (ri,~&.>&>i.#ri)}1000 28$0
1000 28
   rs2-:rs
1


On 8/27/07, Ralph G Selfridge <[EMAIL PROTECTED]> wrote:
>
> 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.
>
>
> Ralph S
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to