in reply to Re: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's
in thread Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's
UPDATE this code is wrong as noticed by choroba and hippo. See below why
Hello Eily,
L*I find even more intuitive to use permutations directly:
use strict; use warnings; use feature 'say'; use Algorithm::Combinatorics qw(permutations); my $zeros = 7; my $ones = 3; # if you want the iterator force scalar context, as in: # my $iter = permutations(\@data); say join('',@$_) for permutations( [ (0) x $zeros, (1) x $ones] );
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's -- permutations
by choroba (Cardinal) on Sep 18, 2020 at 09:12 UTC | |
Re^3: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's -- permutations
by hippo (Bishop) on Sep 18, 2020 at 09:21 UTC | |
by Discipulus (Canon) on Sep 18, 2020 at 10:05 UTC | |
Re^3: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's
by Eily (Monsignor) on Sep 18, 2020 at 08:39 UTC |
In Section
Seekers of Perl Wisdom