Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
P is for Practical
 
PerlMonks  

Re: Re: Re: Character Combinations

by chunlou (Curate)
on Aug 22, 2003 at 19:36 UTC ( [id://285958]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

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

Replies are listed 'Best First'.
Re: Re: Re: Re: Character Combinations
by Limbic~Region (Chancellor) on Aug 22, 2003 at 19:47 UTC
    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

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://285958]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.