Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's

by Tux (Canon)
on Sep 18, 2020 at 12:22 UTC ( #11121917=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub tux_for {
        my ($length, $ones) = @_;
    ...
            0 .. oct "0b".join""=> (1) x $ones, (0) x ($length - $ones)
            ];
        }
    
  2. or download this
    use Algorithm::FastPermute;
    
    ...
        permute { $seen{join "" => @l}++ } @l;
        [ keys %seen ];
        }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-12-09 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?