Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Re: Re: Character Combinations

by Limbic~Region (Chancellor)
on Aug 22, 2003 at 23:47 UTC ( #285960=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: Character Combinations
in thread Character Combinations

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


Comment on Re: Re: Re: Re: Character Combinations
Select or Download Code
Re: Re: Re: Re: Re: Character Combinations
by chunlou (Curate) on Aug 23, 2003 at 01:05 UTC
    Silly me. Should have consulted with this: Permutations and combinations.
    use Algorithm::FastPermute; sub combinations { return [] unless @_; my $first = shift; my @rest = combinations(@_); return @rest, map { [$first, @$_] } @rest; } for(combinations('a'..'c')){ my @c = @{$_}; permute {print @c , "\n"} @c; } __END__ c b bc cb a ac ca ab ba abc acb cab bac bca cba

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2015-07-03 16:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (54 votes), past polls