Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Matching permutations with regex

by Eily (Monsignor)
on Nov 20, 2018 at 14:01 UTC ( [id://1226072]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use v5.20;
    use Data::Dump "pp";
    
    ...
    {
        $j =~ $z and say pp {$j => \@- };
    }
    
  2. or download this
    ...
    { acbcaa => [0, 6, 6, 3, 3, 4, 4] }
    { acbcab => [0, 5, 5, 6, 6, 4, 4] }
    ...
    { cccbca => [0, 6, 6, 4, 4, 5, 5] }
    { ccccab => [0, 5, 5, 6, 6, 4, 4] }
    { ccccba => [0, 6, 6, 5, 5, 4, 4] }
    
  3. or download this
    my @y = glob('{a,b,c}'x6);
    my $y = '(?:(?!\1)a()|(?!\2)a()|(?!\3)b()|(?!\4)b()|(?!\5)c()|(?!\6)c(
    +)){6}\1\2\3\4\5\6';
    
    ...
    {
        $j =~ $y and say $j;
    }
    
  4. or download this
    aabbcc
    aabcbc
    aabccb
    ...
    ccbaab
    ccbaba
    ccbbaa
    
  5. or download this
    # edit reformatted as a multiline regex for clarity
    my $y = qr/(?:
                   (?!\1) a ()
    ...
                 | (?!\6) c ()
               ){6}
             /x;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-18 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found