Not the most efficient solution, but I tried to make it easy to read for you...$ cat 652805.pl #!/usr/bin/perl -w # # Generate all possible subsequences of sequence 1 # use strict; use warnings; # Sequence 1 my @seq_1 = ('a', 'b', 'c', 'd', 'e'); # Count of all possible subsequences my $s1_max = 2 ** @seq_1; print "Number of possible subsequences: ", $s1_max,"\n"; # To get each possible subsequence, use a binary number # as a mask to tell you which digits to print for my $seq (0 .. $s1_max-1) { print "Sequence ", $seq, ": "; my $bit = 0; while ($bit < @seq_1) { print $seq_1[$bit], " " if 2**$bit & $seq; ++$bit; } print "\n"; }
...roboticus
In reply to Re^3: True Brute Force Longest Common Sub Sequence
by roboticus
in thread True Brute Force Longest Common Sub Sequence
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |