Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Character Combinations

by chunlou (Curate)
on Aug 22, 2003 at 23:00 UTC ( #285950=note: print w/replies, xml ) Need Help??


in reply to Character Combinations

Why not use List::Permutor or Algorithm::FastPermute?
use Algorithm::FastPermute; my @c = 'a'..'c'; permute {print "@c\n"} @c; __END__ a b c a c b c a b b a c b c a c b a

Replies are listed 'Best First'.
Re: Re: Character Combinations
by Limbic~Region (Chancellor) on Aug 22, 2003 at 23:06 UTC
    chunlou,
    Permutations are not combinations. For instance - say I wanted to find all combinations of 4 character strings with each position able to be 26 different letters. This is what I believe is being asked for. I am pretty sure there is an iterative solution - but all I can come up with right now are recursive ones.

    Cheers - L~R

      You mean this?
      use Algorithm::FastPermute; my @c = ('a'..'c'); for my $i (0..2) { for my $j (0..2) { my @c = @c[$i..$j] if $i <= $j; permute {print @c , "\n"} @c; } } __END__ a ab ba abc acb cab bac bca cba b bc cb c
        chunlou,
        Considering that missed ca - no. It also doesn't work if you change
        my @c = ('a'..'c');
        to
        my @c = ('a'..'z');

        Permutations are not combinations.

        L~R

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://285950]
help
Chatterbox?
[Corion]: I just found out that in $current_top_prior ity_project , the part I am in is not even in the top three worries. That's somewhat bad, not because I'm happy with being a top worry but because that means that I don't even know how bad the rest ...
[Corion]: ... of the situation is :-)
[marto]: it's good to know that things can always get worse :P
[hippo]: Ignorance can be bliss
[Corion]: hippo: Yeah - I'll just avoid the project lead :)
[Corion]: marto: Yeah, it helps with the perspective :-D

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2017-07-26 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (385 votes). Check out past polls.