in reply to Permutation with repetitions
In my previous question in this thread I asked to count the number of occurrences of all permutations with repetitions. What if I only wanted to not have the count but a binary answer (i.e. 0 or 1) if a specific permutation is in my string? There must be a way to just change the regexp in a minor way.
Up until now I used the suggested solution of:I know I could set$n=4; $str="abababbcad"; %count; while($str =~ m[(?=([abcd]{$n})).]g){ ++$count{ $1}; }
but this is not desirable since I would like to add to the hash the counts of unique occurrences of other strings. For example:$count{$1}=1
should give the following list:$str1="abad"; $str2="aaab"; $n=2;
|
|---|