Oh, now your question is clearer. The easiest thing is to use a hash to track the frequencies, eg.
my $str = "aaaabdbbdaccdacdaaabdcd"; my $n = 3; my %freq; for my $p (0 .. length($str) - $n) { $freq{substr($str, $p, $n)}++; } for my $ng (sort keys %freq) { printf "%3d %s\n", $freq{$ng}, $ng; }
In reply to Re^5: Permutation with repetitions
by ambrus
in thread Permutation with repetitions
by umeboshi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |