Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

[delphi] generating binary strings

Name: Anonymous 2012-01-19 18:10

How can I generate all binary strings of n length with m ones? (in delphi)
sample: n=3 m=2:
110
101
011

Name: Anonymous 2012-01-19 22:11

>>11
Here, X is the base, but it only finds the strings with M non-zero digits. It could be made more complicated to allow the number of each kind of digit to be selected.
      ((M←1)=+/0≠A)⌿A←⍉(N/X)⊤⍳(X←3)*N←3
0 0 1
0 0 2
0 1 0
0 2 0
1 0 0
2 0 0

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List