http://qs321.pair.com?node_id=11121897


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,

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] );
L*

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.