Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Getting permutations of length n of an array of length greater than n?

by pryrt (Abbot)
on Jan 18, 2022 at 22:15 UTC ( [id://11140591]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # but also you can create r of n objects permutation generator, where 
    +r <= n
    my $p = Algorithm::Permute->new([1..4], 3);
    
  2. or download this
    C:\usr\local\share>perl -MAlgorithm::Permute -e "my $p=Algorithm::Perm
    +ute::->new([1..4],2); while(my @res=$p->next){print qq(@res\n)}"
    2 1
    ...
    3 4
    4 1
    1 4
    
  3. or download this
    C:\usr\local\share>perl -MAlgorithm::Permute -e "my $p=Algorithm::Perm
    +ute::->new([1..8],5); while(my @res=$p->next){print qq(@res\n)}"
    5 4 3 2 1
    ...
    1 2 8 3 4
    1 2 3 8 4
    1 2 3 4 8
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-28 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found