hello!
I have a group of numbers:
group={05, 60, **13, 58**, 47}
I want to count the total presence of this group in a sequence:
seq={78, **13**, 38, 65, 90, 25, 52, 77, 12, 33, **58**, 83, 20, 45, 70, 7, 32, 57}
Total[SequenceCount[seq, {#}] & /@ group]
out:
2
now I have a group of 6 sub-sequences, I want to count the total presence of the first group in each sub-sequence:
subseq={{20, 3, 76, 17, 90, 73, 14, 87, 70, 65, 48, 31, 62, 45, 28, 59, 42, 25}, {48, 83, 28, 55, 90, 35, 62, 7, 42, 3, 38, 73, 10, 45, 80, 17, 52, 87}, {38, 59, 80, 69, 90, 21, 10, 31, 52, 83, 14, 35, 24, 45, 66, 55, 76, 7}, {14, 85, 66, 19, 90, 71, 24, 5, 76, 59, 40, 21, 64, 45, 26, 69, 50, 31}, {40, 33, 26, 7, 90, 83, 64, 57, 50, 85, 78, 71, 52, 45, 38, 19, 12, 5}, {78, 13, 38, 65, 90, 25, 52, 77, 12, 33, 58, 83, 20, 45, 70, 7, 32, 57}}
(in fact my list of sub-sequences is 3240 items)
I tried with PART and EXTRACT but it does not work
if I manually enter PART # or EXTRACT # it works:
Total[SequenceCount[subseq[[6]], {#}] & /@ group]
Total[SequenceCount[Extract[subseq, 6], {#}] & /@ group]
out:
2
2
but if I attribute to the # sub-sequence list, it does not work:
Total[SequenceCount[subseq[[#]]&/@Range[6], {#}] & /@ group]
or
Total[SequenceCount[Extract[subseq, #]&/@Range[6], {#}] & /@ group]
out:
0
0
what I want to get is this:
{0, 0, 0, 1, 1, 2}
which are the presence of the 5 GROUP numbers in each 6 SUBSEQ sub-sequence
Can anyone help me?
tnk’s