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

Re: Is it possible to generate all possible combinations of 2-letter and 3-letter words in perl?

by Khen1950fx (Canon)
on Sep 02, 2012 at 16:31 UTC ( #991304=note: print w/replies, xml ) Need Help??


in reply to Is it possible to generate all possible combinations of 2-letter and 3-letter words in perl?

Set::CrossProduct.
#!/usr/bin/perl use autodie; use common::sense; use Set::CrossProduct; my $min = 2; my $max = 3; my $set = [ qw(A T G C) ]; foreach my $length ( $min .. $max ) { say "Getting combinations of length $length"; my $cross = Set::CrossProduct->new( [ ( $set ) x $length ] ); while( my $tuple = $cross->get ) { say join '', @$tuple; } }
  • Comment on Re: Is it possible to generate all possible combinations of 2-letter and 3-letter words in perl?
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2016-09-25 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (470 votes). Check out past polls.