Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re^2: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1'sby salva (Canon) |
on Sep 18, 2020 at 07:38 UTC ( [id://11121894]=note: print w/replies, xml ) | Need Help?? |
Generating all the combination and then filtering out those that don't have the right number of ones can be pretty inefficient, specially when the number of zeros is big and the number of ones small.
In any case, you can also use a regular expression for generating all the binary numbers of some given length :-)
In Section
Seekers of Perl Wisdom
|
|