Skip to main content
Tweeted twitter.com/#!/StackMma/status/562019311821520896
added 10 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

I would like to count the number of subsequences in list. Say I have data given by:

data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1};

data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1};

I would like to count the number times I see the following subsequences: {1,1}, {1,2}, {2,1}, {2,2}{1,1}, {1,2}, {2,1}, {2,2}. Is there a quick way to do so? I've tried a few approaches using CountCount and CasesCases with no luck. Any advice would be greatly appreciated.

Thanks!

I would like to count the number of subsequences in list. Say I have data given by:

data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1};

I would like to count the number times I see the following subsequences: {1,1}, {1,2}, {2,1}, {2,2}. Is there a quick way to do so? I've tried a few approaches using Count and Cases with no luck. Any advice would be greatly appreciated.

Thanks!

I would like to count the number of subsequences in list. Say I have data given by:

data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1};

I would like to count the number times I see the following subsequences: {1,1}, {1,2}, {2,1}, {2,2}. Is there a quick way to do so? I've tried a few approaches using Count and Cases with no luck. Any advice would be greatly appreciated.

Thanks!

Source Link

Counting subsequences (i.e., patterns) within a list?

I would like to count the number of subsequences in list. Say I have data given by:

data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1};

I would like to count the number times I see the following subsequences: {1,1}, {1,2}, {2,1}, {2,2}. Is there a quick way to do so? I've tried a few approaches using Count and Cases with no luck. Any advice would be greatly appreciated.

Thanks!