in reply to Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's
You can use a regular expression!!!
my $length = 10; my $ones = 4; my $str = ("1" x $ones) . ("0" x ($length - $ones)); while(1) { print "$str\n"; $str =~ s/^(0*)(1*)10/${2}${1}01/ or last }
|
---|
In Section
Seekers of Perl Wisdom