Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: all permutations of given lenght

by Eily (Monsignor)
on Aug 11, 2020 at 07:55 UTC ( #11120597=note: print w/replies, xml ) Need Help??

in reply to all permutations of given lenght

Algorithm::Combinatorics probably has what you want (probably not a permutation though, since it would be the same length as the input, without introducing repetitions). Either variations_with_repetition or combinations_with_repetition should be what you're looking for. The first one considers (A, B, B), (B, A, B), and (B, B, A) to be three different solutions (so produces the three), while the second will only produce (A, B, B) and consider the other two to be identical.

Replies are listed 'Best First'.
Re^2: all permutations of given lenght
by cataclismic_user (Novice) on Aug 11, 2020 at 08:23 UTC
    Many thanks! variations_with_repetitions has done the job nicely!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2023-03-24 04:16 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.