Presumably, you don't want to count substrings that would be formed by the removal of the Xs?
Also, you mentioned earlier having all the permutations, including those with zero occurances, in the results hash. The problem with that is that by the time you get to n=13, you'd have 67 million entries in the hash, most of which would be 0.
Anyway, this might be of some use:
$s = 'aaaabccbaxxxcbddadcc';;
++$h{ $1 } while $s =~ m[(?=([abcd]{3})).]g;;
pp \%h;;
{
aaa => 2,
aab => 1,
abc => 1,
adc => 1,
bcc => 1,
bdd => 1,
cba => 1,
cbd => 1,
ccb => 1,
dad => 1,
dcc => 1,
dda => 1,
}
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.